From patchwork Mon Nov 6 00:54:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Wanpeng Li X-Patchwork-Id: 10042451 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 8B632601EB for ; Mon, 6 Nov 2017 00:56:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9D0A129224 for ; Mon, 6 Nov 2017 00:56:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 907192922E; Mon, 6 Nov 2017 00:56:11 +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 3BE2529224 for ; Mon, 6 Nov 2017 00:56:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751387AbdKFAy7 (ORCPT ); Sun, 5 Nov 2017 19:54:59 -0500 Received: from mail-pf0-f193.google.com ([209.85.192.193]:49305 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750910AbdKFAy4 (ORCPT ); Sun, 5 Nov 2017 19:54:56 -0500 Received: by mail-pf0-f193.google.com with SMTP id i5so6476153pfe.6; Sun, 05 Nov 2017 16:54:56 -0800 (PST) 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=E6e1kKx4qG47c5t4uree0OJnuSQfExKkt3lxT9FB/4Q=; b=D/l3lLX0m7YpN8JwAYIPkBkKxPWn7l3om2sX8pPHuACOei74KmIGksavCEheZaPIom /kQfMt0OZXy6x6z5QCQl4lHSZLOCeJNDUOZT5IuMpGKrZEEvXtD7gLc2Y/vcqHODEPzY aL2cZ2uPFRW3GdkX4EHUuOjgi/VsUUTRuIqRqUlVNortrwod6a9a+uVcVibN1gJ2j4lx lspf3/wtACd9Os7tHeNi+gKPWUox/tPosIEigUCBSTMNh2ABt6Gl0eX829QAxrQFl5p3 aiURqNjy29b75L3yY4qLP5X5lXIGuxmilgDl97Li19c3JDHlD/tVVqBlVAFP5JhDyoXP Hn9w== 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=E6e1kKx4qG47c5t4uree0OJnuSQfExKkt3lxT9FB/4Q=; b=REu6nCOh3+SXGqSPC4Th8iTtXnSzRSkkuPAgDIFkL3u44MyfDIQwQGfMSbCfm9sHgm arcPtOz0RPlwluhXApQbA75PXTjKU1vpZn8beWulGY5+B4Re5WCjeEJtNtfHRevS9ki0 wRoZ6/cNEARzDDrHlTJ1au190ZfGlCb+TuoN5cjF2wAtzuRaF7TMejc8fbAWB9mFRQL3 bGLofx+6Q/27Gv0aFQXTZBXJwSTDPcMKNsouYXyr57sMuQpU6yTnvdIITa40tVKmSfH2 EImGif3iDvGqMPMdqxR7QH+mWvSiXHJd0/X/ucfYt9Ut/Omt2rzGAxZTAUKS/8lVxpmc Wh7Q== X-Gm-Message-State: AMCzsaVUidSUU1bmVWQzuvPeu+mYaf+jyJjGQXO3VXIvCrmMJk1mPEVB 32ZreumS/be47L1eWT07XRKBUQ== X-Google-Smtp-Source: ABhQp+R6xHWMdXvN/WLLghh3auchRlD2gIhl6FKW6wILnLss4DrRzDPIsNgR0dyyeZLR3UESSMnmZQ== X-Received: by 10.99.121.201 with SMTP id u192mr13680240pgc.69.1509929696064; Sun, 05 Nov 2017 16:54:56 -0800 (PST) Received: from localhost ([203.205.141.123]) by smtp.gmail.com with ESMTPSA id f1sm19494152pfe.150.2017.11.05.16.54.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 05 Nov 2017 16:54:55 -0800 (PST) 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 v6 2/3] KVM: nVMX: Validate the IA32_BNDCFGS on nested VM-entry Date: Sun, 5 Nov 2017 16:54:48 -0800 Message-Id: <1509929689-2935-2-git-send-email-wanpeng.li@hotmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1509929689-2935-1-git-send-email-wanpeng.li@hotmail.com> References: <1509929689-2935-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 Reviewed-by: Paolo Bonzini --- v5 -> v6: * keep the right conjunct 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 ((vmcs12->vm_entry_controls & VM_ENTRY_LOAD_BNDCFGS) && + (is_noncanonical_address(vmcs12->guest_bndcfgs & PAGE_MASK, vcpu) || + (vmcs12->guest_bndcfgs & MSR_IA32_BNDCFGS_RSVD))) + return 1; + return 0; }