From patchwork Mon Nov 12 20:44:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Mattson X-Patchwork-Id: 10679231 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 740BE13B5 for ; Mon, 12 Nov 2018 20:44:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 661D029C46 for ; Mon, 12 Nov 2018 20:44:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 595472A5EF; Mon, 12 Nov 2018 20:44:12 +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=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham 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 084D229C46 for ; Mon, 12 Nov 2018 20:44:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729470AbeKMGjE (ORCPT ); Tue, 13 Nov 2018 01:39:04 -0500 Received: from mail-it1-f202.google.com ([209.85.166.202]:35431 "EHLO mail-it1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725861AbeKMGjD (ORCPT ); Tue, 13 Nov 2018 01:39:03 -0500 Received: by mail-it1-f202.google.com with SMTP id e19-v6so8618208itc.0 for ; Mon, 12 Nov 2018 12:44:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=j1EazihaPpCDX3xk0jW8cPBkb5jUYLNjbT8UbODOL7A=; b=XaZYSYTG8soRn98LMDnMYN9j+fi1VYoGjpSrrWPl7fYfeZtHZRkFulrp1VEsDDbV7b lxLiWZTfv3Hpe/ZV0+kMYJEOI168DF+XM8bUiH4fwmMaXWVL5cjdpYTN+AXTuPQTcinX ZCJYrNwenFvUTpXhzk/1kkiLHVXLIdqgXEC3Sogad4ujs8ZHXvmv0EuMcstKftxNM6vr nLjPVoc/N43JHAOHzXsDdSVM11dGg6IYJTdnuPldLNPW5o8DqLIgopKlTW1B4bxfP2Tm 0Ug1zJv3YInXrK2ySXXBElxLNirb9KLM9JX1h7ud42yBlRDIFE1QQ3Vr7m/bfOt3ZINo h2PQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=j1EazihaPpCDX3xk0jW8cPBkb5jUYLNjbT8UbODOL7A=; b=LWWQcyUp4yx+vOG44FDQjc2vqwUh7uLXQ6INjaDYkQvfVkBL9u6VQNHSbVmWaytGpW U3HJX60wfYbtCgFdcEnsh/b8hV1e1xuh4z4DDT98n/8pNonunAsxOHQ5mOPC4dXrdd2W ZcuHAAugWoZTo/AtsWghgvZ/pIocvefWIipyTpBXJv5vxgHx0NlBuD2FC+EOicuk11Eh SfmFjqycqprB0gFtYH00mrtGtEq3ZKe/zjPb7IdFCdQ286063uFHAq1h0A1TSIj1fFqq IhTDOG+Y0LXSFcYtbTC/OaEv52tNbyQDMaF6h7fdrXXLbCZJRP8YrdUHzPVEm8BNZlJY rHdQ== X-Gm-Message-State: AGRZ1gL24acQlnUZguIuC29Y7w3U7c8wnAJVtZL8dVGDQXSEn+DFb6Ft pRCCGdVDLQlgK15U+/3057dFIceqT6YeIafWiDRrMkiyEieur7hDd+GqT04mA+gT4P9q8yQTNXG /QusGk+hG/r3cKJHPbaua3mxHKkxpybS8z0xjNZRO66S7kmvYGntZJiRbGowpKSw= X-Google-Smtp-Source: AJdET5cJ2P0oelQ/eublWIG99KYke3HHqiwKPZOYpynMgPedxOz8lJf6bKShgtqbvgls2EQA5zru8BoBjh81+A== X-Received: by 2002:a24:1f46:: with SMTP id d67-v6mr973622itd.36.1542055449120; Mon, 12 Nov 2018 12:44:09 -0800 (PST) Date: Mon, 12 Nov 2018 12:44:01 -0800 In-Reply-To: <20181109222042.60248-1-jmattson@google.com> Message-Id: <20181112204401.261404-1-jmattson@google.com> Mime-Version: 1.0 References: <20181109222042.60248-1-jmattson@google.com> X-Mailer: git-send-email 2.19.1.930.g4563a0d9d0-goog Subject: [PATCH v3 1/4] kvm: vmx: Set IA32_TSC_AUX for legacy mode guests From: Jim Mattson To: kvm@vger.kernel.org Cc: Jim Mattson , Peter Shier , Marc Orr , Liran Alon Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP RDTSCP is supported in legacy mode as well as long mode. The IA32_TSC_AUX MSR should be set to the correct guest value before entering any guest that supports RDTSCP. Fixes: 4e47c7a6d714 ("KVM: VMX: Add instruction rdtscp support for guest") Signed-off-by: Jim Mattson Reviewed-by: Peter Shier Reviewed-by: Marc Orr Reviewed-by: Liran Alon --- arch/x86/kvm/vmx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index ccc6a01eb4f4..120fc97a63fc 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -3415,9 +3415,6 @@ static void setup_msrs(struct vcpu_vmx *vmx) index = __find_msr_index(vmx, MSR_CSTAR); if (index >= 0) move_msr_up(vmx, index, save_nmsrs++); - index = __find_msr_index(vmx, MSR_TSC_AUX); - if (index >= 0 && guest_cpuid_has(&vmx->vcpu, X86_FEATURE_RDTSCP)) - move_msr_up(vmx, index, save_nmsrs++); /* * MSR_STAR is only needed on long mode guests, and only * if efer.sce is enabled. @@ -3430,6 +3427,9 @@ static void setup_msrs(struct vcpu_vmx *vmx) index = __find_msr_index(vmx, MSR_EFER); if (index >= 0 && update_transition_efer(vmx, index)) move_msr_up(vmx, index, save_nmsrs++); + index = __find_msr_index(vmx, MSR_TSC_AUX); + if (index >= 0 && guest_cpuid_has(&vmx->vcpu, X86_FEATURE_RDTSCP)) + move_msr_up(vmx, index, save_nmsrs++); vmx->save_nmsrs = save_nmsrs; From patchwork Mon Nov 12 20:45:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Mattson X-Patchwork-Id: 10679233 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F4151109C for ; Mon, 12 Nov 2018 20:45:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E47CD2A5EF for ; Mon, 12 Nov 2018 20:45:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D8ABF2A62B; Mon, 12 Nov 2018 20:45:14 +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=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham 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 66AA62A5EF for ; Mon, 12 Nov 2018 20:45:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730158AbeKMGkH (ORCPT ); Tue, 13 Nov 2018 01:40:07 -0500 Received: from mail-pl1-f201.google.com ([209.85.214.201]:54837 "EHLO mail-pl1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725861AbeKMGkG (ORCPT ); Tue, 13 Nov 2018 01:40:06 -0500 Received: by mail-pl1-f201.google.com with SMTP id k14-v6so7952469pls.21 for ; Mon, 12 Nov 2018 12:45:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=vtagQekhQJXPG+xzsGI7mExNCMsnJFENNGuTVqP4NUU=; b=ejP+nj/S6wjhVKP3K5PEURXP5dh4Wq5A87OAUmJyKlNxzvTcF+EI28S9u2Eef9PktL UJMS+sfU0dGtMPeuMGRvjvpzRcpnuyZXkJsKAm77HrhdMwNeV45epWmiDojYFRuQ0ruL o0/wkZZS/5+qlSL9oQpbBqxjDjUh879K/14Lwf2WJ3TP4yGahYEInOeCXuR7cPJO370F ebkaYApkC8jjJEy5bUvVRGMrFS6S0LQr8uigNzQSPjdGTdACoCvtNH6W22wz92E+EXD+ K5Cg+BDSZ7ZUdt/DCK3AkAH5pN3Y6+KIsz6jytkIz80Gx3cnMxYjJLA65N8x2okzdQsh iCIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=vtagQekhQJXPG+xzsGI7mExNCMsnJFENNGuTVqP4NUU=; b=J0qgCM5Z17OsjUweJV5sW3HR+AwkqHdqxmEK8bqUnJQHMFX4X94WSFWVcADGfekJok 7ZM0kmODViQ+gVysnQ0d7c+rp53yOYiuZHLZQ2037Suv1gk7xG1/o92ouY3A8TXPUTbo 18brSBlOTrPebt5f0+AQhWGfj6vbGUx3i5E4UelJD7XaNEhOmJqBiYXKifRgosocSJK7 6kquXROEC8gEZ31Qh2ePGpUQONUwcwb/pzKyI163ix+BLrXm1CEpR8lrQDOvKvl29cu6 ptmF0mpXAcnFMrYC1O/cF8S4sTOhMHmPJpDesxctx1Sb/NAI7S7k0sxHYSTPRk1MQgjo I9rw== X-Gm-Message-State: AGRZ1gIHP9DFvMaGvEuLEPDjIW6BqO8KrmF7X/zchuHWWfPlU4eTk1tn BjbZwKoE60s5QdhuyKrezNYSgonv6nMCkLuJAF2Etu98utVkjhyYTRytNmz/+W78VH2ddWLynTf k7bFUpoDQp9lK9/2XZUGkQt/l0CmuJCS2L0bUzUnBb9ZOSlwsXMEPg/FctNauYFY= X-Google-Smtp-Source: AJdET5dttGBuEI8Wv3jz2BrCf+0v+grgoguvcSAbU/MRLEljIY2cWrLW2kV9mmHrHyLIJs+HGrCTl5KN0Dn1oQ== X-Received: by 2002:a65:4083:: with SMTP id t3-v6mr353534pgp.43.1542055512572; Mon, 12 Nov 2018 12:45:12 -0800 (PST) Date: Mon, 12 Nov 2018 12:45:08 -0800 In-Reply-To: Message-Id: <20181112204508.261895-1-jmattson@google.com> Mime-Version: 1.0 References: X-Mailer: git-send-email 2.19.1.930.g4563a0d9d0-goog Subject: [PATCH v3 2/4] kvm: vmx: Document the need for MSR_STAR in i386 builds From: Jim Mattson To: kvm@vger.kernel.org Cc: Jim Mattson , Peter Shier Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add a comment explaining why MSR_STAR must be included in vmx_msr_index[] even for i386 builds. The elided comment has not been relevant since move_msr_up() was introduced in commit a75beee6e4f5d ("KVM: VMX: Avoid saving and restoring msrs on lightweight vmexit"). Signed-off-by: Jim Mattson Reviewed-by: Peter Shier --- arch/x86/kvm/vmx.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 120fc97a63fc..ee460a21d369 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -1388,8 +1388,11 @@ static u64 host_efer; static void ept_save_pdptrs(struct kvm_vcpu *vcpu); /* - * Keep MSR_STAR at the end, as setup_msrs() will try to optimize it - * away by decrementing the array size. + * Though SYSCALL is only supported in 64-bit mode on Intel CPUs, kvm + * will emulate SYSCALL in legacy mode if the vendor string in guest + * CPUID.0:{EBX,ECX,EDX} is "AuthenticAMD" or "AMDisbetter!" To + * support this emulation, IA32_STAR must always be included in + * vmx_msr_index[], even in i386 builds. */ static const u32 vmx_msr_index[] = { #ifdef CONFIG_X86_64 From patchwork Mon Nov 12 20:47:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Mattson X-Patchwork-Id: 10679235 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 12B5913B5 for ; Mon, 12 Nov 2018 20:47:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 037362A635 for ; Mon, 12 Nov 2018 20:47:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EBA822A637; Mon, 12 Nov 2018 20:47:34 +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=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham 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 9CC252A635 for ; Mon, 12 Nov 2018 20:47:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728505AbeKMGm1 (ORCPT ); Tue, 13 Nov 2018 01:42:27 -0500 Received: from mail-io1-f74.google.com ([209.85.166.74]:36392 "EHLO mail-io1-f74.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725861AbeKMGm1 (ORCPT ); Tue, 13 Nov 2018 01:42:27 -0500 Received: by mail-io1-f74.google.com with SMTP id w5-v6so11108566ioj.3 for ; Mon, 12 Nov 2018 12:47:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=lvO/89UIlRwac5jIbA1ThVAvGtoPR4/KGOR7LTsBEAI=; b=l03bEsC0UzVdkY5JmASSQMY3jRMgw0tIE5tVIXh7t5xDG2zvgMTmWTFPYB2LmX08NX fQ2JgR0IkDSX5fZsfEOI0Sys8Z72SrBttNSVZsYcyDqK+q2ilcGXsQT828WlupC2KPug IZcicVA4UzdzjPFS4Wt8WgoSYou+ohRjsJlOmdxqZSdQXfVbjkGkrEtuH2j/+AAlv6V/ eB4NS4dvPD098A3P6wgy0onkHmpSaOhw3Vm/qpJojgSPSNVMURXbGLPy+1voBWJeXgCs aA72fTTzPgXm2sfBIV5LFJNqrH2I6+vPkZB5W/B1KFdt4oIhPqzIQc4Eqvk1uje/rROZ FQFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=lvO/89UIlRwac5jIbA1ThVAvGtoPR4/KGOR7LTsBEAI=; b=le5Zlvy9DsWWrOwD8lLHMFW/+bfGIZ6U1fSmQPbKxDbEe79lHI5VCyYHkvNG4ap9vf 6O1p41uo7y9MM+6xyDra1Y4m6gmx8tOU4WdF+VYJUz/s5G9FxuWfaGIUjPFFdd3pY+AN GejbqFILCu0A4O3u6kLRlKQHc+RG8Zv3SM28C4Golvq32BQVRUcTz2ltZY06KlSOzf8e z0OgPmcv4srMoYPoaGbUPEpDk0xed0HDQ03g/EEv2+jDopnC1AQ8hEjeOr7HIAcN+5r1 JGOwf9OIBd2HqeW3yGxp1ekiEmbskCG1eFldSur3whj/nmszlmOZacWZdU3GTAXkjEvb qViA== X-Gm-Message-State: AGRZ1gIuCraLPDmTXuB4qltqk0QB9dAiQ8qfIPEjlKTaMlDNFPihWORv BPiIxwtwOOl/goEW+hru1JJdveVaEOr35r4CmEN5KkhMOB2MA4dRBQJOGykTgqv5rW8AepR42gq HtmNAxJMCO6pu7JMrmGXJUJaM6BbHK7FdIJkDvdW6jceJwbC9O9sdALicgoGymLs= X-Google-Smtp-Source: AJdET5eRnzvc9+6jELNX2oCgVGVj8iZlvKdB7PPfwh+FTewnVqbsup6I17p9FCVrOACEX1SFipXlLEAT7vAxgg== X-Received: by 2002:a24:6c90:: with SMTP id w138-v6mr978959itb.12.1542055652151; Mon, 12 Nov 2018 12:47:32 -0800 (PST) Date: Mon, 12 Nov 2018 12:47:28 -0800 In-Reply-To: <20181109222131.60885-2-jmattson@google.com> Message-Id: <20181112204728.674-1-jmattson@google.com> Mime-Version: 1.0 References: <20181109222131.60885-2-jmattson@google.com> X-Mailer: git-send-email 2.19.1.930.g4563a0d9d0-goog Subject: [PATCH v3 3/4] kvm: vmx: Don't set hardware IA32_CSTAR MSR on VM-entry From: Jim Mattson To: kvm@vger.kernel.org Cc: Jim Mattson , Peter Shier Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP SYSCALL raises #UD in compatibility mode on Intel CPUs, so it's pointless to load the guest's IA32_CSTAR value into the hardware MSR. IA32_CSTAR still provides 48 bits of storage on Intel CPUs that have CPUID.80000001:EDX.LM[bit 29] set, so we cannot remove it from the vmx_msr_index[] array. Signed-off-by: Jim Mattson Reviewed-by: Peter Shier --- arch/x86/kvm/vmx.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index ee460a21d369..df468980a8c1 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -3413,9 +3413,6 @@ static void setup_msrs(struct vcpu_vmx *vmx) if (index >= 0) move_msr_up(vmx, index, save_nmsrs++); index = __find_msr_index(vmx, MSR_LSTAR); - if (index >= 0) - move_msr_up(vmx, index, save_nmsrs++); - index = __find_msr_index(vmx, MSR_CSTAR); if (index >= 0) move_msr_up(vmx, index, save_nmsrs++); /* From patchwork Mon Nov 12 20:48:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Mattson X-Patchwork-Id: 10679237 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 41058109C for ; Mon, 12 Nov 2018 20:48:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3197328A19 for ; Mon, 12 Nov 2018 20:48:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 225FD2A635; Mon, 12 Nov 2018 20:48:22 +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=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham 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 C3DAC28A19 for ; Mon, 12 Nov 2018 20:48:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726702AbeKMGnP (ORCPT ); Tue, 13 Nov 2018 01:43:15 -0500 Received: from mail-pl1-f201.google.com ([209.85.214.201]:43187 "EHLO mail-pl1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725861AbeKMGnP (ORCPT ); Tue, 13 Nov 2018 01:43:15 -0500 Received: by mail-pl1-f201.google.com with SMTP id e97-v6so7974008plb.10 for ; Mon, 12 Nov 2018 12:48:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=QA61z02Rjw7YCieorPgrDvC/WwOVmzk2QaZdPPGopoI=; b=vrsY/BhhN/MWPhiW3yB8/ap1v9iSXkWcc7IdlFX/azvYUoEnIwNz/FXxJq51Cl6KgP GYLcibSFH7hv5Sz0JSklpUnDTqMQZ+JkcmMq53mC35zhrdl51ON4RaG7SyRxrG5bX7sp 4D7qe07OXeRbVIO1e8zQb+yhUGRNSlMYSI1nXfrYMFqvbswDMMjYrGqARPJP06R/572N tODFQi+MPl757z8HH86rZ+FppYhGJKXeAwRsGESp3yCHRbykOoyLHougAykYdJXi5Oec 0Cv4gVead088lvCzQN/6ODaxhoYqAb+Jpv2azJmBeOeN/jhkWn2CJQPJvsj1JGBjaEKx vfqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=QA61z02Rjw7YCieorPgrDvC/WwOVmzk2QaZdPPGopoI=; b=bgBuCysVsG7ran6ToeLv+HWFx+3xihNg5Bmq/HjSkDFSLpvHV/V7hp/Wja5HN8xA5C ztGulzKlFnHwXcmAmx9StNdDBM1KbH5SnbUJ8fNsRCEmF1TjDrIEPGsrKgnOJxT7ocIj ExwwL3Af43YnZ393volqKehAr28dGpUqECK5z4yFY3Ck4ptEUc5uOCjMWNHhVLE2iXP+ gRIPBu/pVGcc1eOUX5A2HWKqfWUqtIGaaDy4Ur4/VLBfIsatQkas8KH9MlWFGqLpiJZh pgqcV7uLZ0jtzdYSmawVN5LAgUijGuvJrIFPAGVqKpVPvx9CC4AYN4frFwCkypGt6vt/ mjow== X-Gm-Message-State: AGRZ1gJsVj7xyQ20FfRAb6Z8Voqn3Ppkx6dk+y+rf91mvoLbuJ3uJVJa sdYHfnimPhrK9xO3ylGkPAYMeqVC8pgZG2gWmJjr3wU+IMm/zOIpX7zmiwrKdgutlbyFnrQEvyI tqT2mcpDQfT1UkNd8jvni3Y0k+PxhhukOvrmuFQWdZu1ZazWyfL96Z7hFFmucr5M= X-Google-Smtp-Source: AJdET5db9EyAp8LHb8AhuGPA7jS+5J8ioj/Jc0LTyQi9lj+hnfTnNmBmLSi+DjL7K8XhOvSzlV2XBKPktDsxqg== X-Received: by 2002:a62:f51b:: with SMTP id n27-v6mr1113690pfh.115.1542055699918; Mon, 12 Nov 2018 12:48:19 -0800 (PST) Date: Mon, 12 Nov 2018 12:48:16 -0800 In-Reply-To: <20181109222131.60885-3-jmattson@google.com> Message-Id: <20181112204816.1524-1-jmattson@google.com> Mime-Version: 1.0 References: <20181109222131.60885-3-jmattson@google.com> X-Mailer: git-send-email 2.19.1.930.g4563a0d9d0-goog Subject: [PATCH v3 4/4] kvm: vmx: Skip all SYSCALL MSRs in setup_msrs() when !EFER.SCE From: Jim Mattson To: kvm@vger.kernel.org Cc: Jim Mattson , Peter Shier , Marc Orr Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Like IA32_STAR, IA32_LSTAR and IA32_FMASK only need to contain guest values on VM-entry when the guest is in long mode and EFER.SCE is set. Signed-off-by: Jim Mattson Reviewed-by: Peter Shier Reviewed-by: Marc Orr --- arch/x86/kvm/vmx.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index df468980a8c1..efcaaf167e6b 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -3408,19 +3408,19 @@ static void setup_msrs(struct vcpu_vmx *vmx) save_nmsrs = 0; #ifdef CONFIG_X86_64 - if (is_long_mode(&vmx->vcpu)) { - index = __find_msr_index(vmx, MSR_SYSCALL_MASK); + /* + * The SYSCALL MSRs are only needed on long mode guests, and only + * when EFER.SCE is set. + */ + if (is_long_mode(&vmx->vcpu) && (vmx->vcpu.arch.efer & EFER_SCE)) { + index = __find_msr_index(vmx, MSR_STAR); if (index >= 0) move_msr_up(vmx, index, save_nmsrs++); index = __find_msr_index(vmx, MSR_LSTAR); if (index >= 0) move_msr_up(vmx, index, save_nmsrs++); - /* - * MSR_STAR is only needed on long mode guests, and only - * if efer.sce is enabled. - */ - index = __find_msr_index(vmx, MSR_STAR); - if ((index >= 0) && (vmx->vcpu.arch.efer & EFER_SCE)) + index = __find_msr_index(vmx, MSR_SYSCALL_MASK); + if (index >= 0) move_msr_up(vmx, index, save_nmsrs++); } #endif