From patchwork Fri Nov 3 00:35:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Wanpeng Li X-Patchwork-Id: 10039421 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C21A86028E for ; Fri, 3 Nov 2017 00:36:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B56D9293F7 for ; Fri, 3 Nov 2017 00:36:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AA77129466; Fri, 3 Nov 2017 00:36:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AB9A6293F7 for ; Fri, 3 Nov 2017 00:36:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964844AbdKCAfi (ORCPT ); Thu, 2 Nov 2017 20:35:38 -0400 Received: from mail-pf0-f194.google.com ([209.85.192.194]:43312 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934561AbdKCAff (ORCPT ); Thu, 2 Nov 2017 20:35:35 -0400 Received: by mail-pf0-f194.google.com with SMTP id a8so956813pfc.0; Thu, 02 Nov 2017 17:35:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=D0P+HZ+lXDRj8LMpegmycWiOezcjh7AI5kLAvF5bVaU=; b=d1TvohhqBej78kDWmjzfL+mT09LYXjXDFttXbk6+3LuZvaJJ9DXS+yIOwmarHjixdZ JF7COKnMbsnNfv1yB9Y/+6+A1DpJGWwKvkX82nrFISP+0cRINMrvdC48RwffkhWg9kya 3HAGr0dTYjiBiFJW3X4dYhJp2uaCurbtDwh1fsFpPwSllsQnX5mDLGgSNWuot9AVusTw JCX1qR75/TLwphQ+xJX/Dqg+aWOR3F3i/pYlUjW2ciWM95F2VJI+C86ysOCSH1FNm7ps ppLGoqUmzC4FrC7RhB69gvJ0gJ50TLmcYGaM5RWjcq3lwiNDZDbhhazuu0WKTy66jxt5 TeIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=D0P+HZ+lXDRj8LMpegmycWiOezcjh7AI5kLAvF5bVaU=; b=n1vEAZZ4zPcrokGQ/Ng089dPRVzFBss4DqRIl2a9cBtMx0UcSBzGZIvtCXOMggD5Ex W6DuAxqBhig2lq8Ankw7pBl1Y5VyeD22VnrPich3kEdH2CYQw8GhMxlKX1in+xuYgEGD +s5cfs7Y+cF2B1CbYeebDJGM6brlJxNcOVKPUTpGjJUat+Iyvw2/5J6Hf6Cwj9+mDeUY tPIXYCxCA+eVxcYWZEXhtF0Yr7F3K/aHVamyROh8vvf9f5glFDfkJKBYK4sir/UAiLEz M45I51RQGsxIG8j9Hop8n3IFzObgRxImdkEukowbDQmfMN8qUWF0oDS0a0jNgX/9U5uu Y84A== X-Gm-Message-State: AMCzsaVEfGtoTn1Dy3p+KrhNL0Vm+IMhnFH5h+HOYXgJKrlI2glFS4XH 9M7NXTG/MIP8F1i64RIFuXSM9Q== X-Google-Smtp-Source: ABhQp+Tx8kdE/A8zAhga//VCj/UQ1mabcNBdtdnX4OWEkjzNSeAn7BUk5Li3Ap4ScyHcHN6G8JDewg== X-Received: by 10.99.119.199 with SMTP id s190mr5420325pgc.110.1509669334604; Thu, 02 Nov 2017 17:35:34 -0700 (PDT) Received: from localhost ([203.205.141.123]) by smtp.gmail.com with ESMTPSA id 24sm8054682pfk.9.2017.11.02.17.35.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 02 Nov 2017 17:35:34 -0700 (PDT) From: Wanpeng Li X-Google-Original-From: Wanpeng Li To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , Wanpeng Li , Jim Mattson Subject: [PATCH v4 2/3] KVM: nVMX: Validate the IA32_BNDCFGS on nested VM-entry Date: Thu, 2 Nov 2017 17:35:26 -0700 Message-Id: <1509669327-3940-2-git-send-email-wanpeng.li@hotmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1509669327-3940-1-git-send-email-wanpeng.li@hotmail.com> References: <1509669327-3940-1-git-send-email-wanpeng.li@hotmail.com> MIME-Version: 1.0 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Wanpeng Li According to the SDM, if the "load IA32_BNDCFGS" VM-entry controls is 1, the following checks are performed on the field for the IA32_BNDCFGS MSR: - Bits reserved in the IA32_BNDCFGS MSR must be 0. - The linear address in bits 63:12 must be canonical. Reviewed-by: Konrad Rzeszutek Wilk Cc: Paolo Bonzini Cc: Radim Krčmář Cc: Jim Mattson Signed-off-by: Wanpeng Li --- v3 -> v4: * simply condition * use && instead of nested "if"s arch/x86/kvm/vmx.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index e6c8ffa..6cf3972 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -10805,6 +10805,11 @@ static int check_vmentry_postreqs(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12, return 1; } + if (kvm_mpx_supported() && + (is_noncanonical_address(vmcs12->guest_bndcfgs & PAGE_MASK, vcpu) || + (vmcs12->guest_bndcfgs & MSR_IA32_BNDCFGS_RSVD))) + return 1; + return 0; }