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