From patchwork Wed May 9 21:29:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Mattson X-Patchwork-Id: 10390867 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 8AF6560153 for ; Wed, 9 May 2018 21:29:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7C21B2018F for ; Wed, 9 May 2018 21:29:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7012527CAF; Wed, 9 May 2018 21:29:52 +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 E21EA2018F for ; Wed, 9 May 2018 21:29:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965168AbeEIV3t (ORCPT ); Wed, 9 May 2018 17:29:49 -0400 Received: from mail-yb0-f201.google.com ([209.85.213.201]:39530 "EHLO mail-yb0-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964968AbeEIV3s (ORCPT ); Wed, 9 May 2018 17:29:48 -0400 Received: by mail-yb0-f201.google.com with SMTP id u40-v6so23705727ybi.6 for ; Wed, 09 May 2018 14:29:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:date:in-reply-to:message-id:references:subject:from:to :cc; bh=6Gkfnq8nZkm1WahegAIUx42JY7Dgy0yhzVvM5Hp0K4A=; b=lV89r9ouiLEa09XVAqQ5HvDq5GsWPtBYW9nBT2GrvPiPoKlZz9p/gOkmvusCODpV4R PDH8qwRiKyUzrNmcdoej74gus9SxMYXMOa8cBto+tA4dJSXMiHQQRldqMaj2QNxhfsNx mfi4WJNWmQMyAbXTw1y92HcYKLx2oS0+5xA1p9coJldiGN6WBFhDcERsUpPgyAVj3Pxg hJ8/0asdVIZMxDGkB1JKMIZ7ZGzHTEssWBJ9SlAzFHNDXlGPrIyW3U5FNZclRMr8Bnek 72hCKEjW1B6c8u/9pH2LJykZoMQQg/FaGFA1LBYny3ed3k9VCqBXNSDvaSgmVct83Kuk 2Bew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:in-reply-to:message-id :references:subject:from:to:cc; bh=6Gkfnq8nZkm1WahegAIUx42JY7Dgy0yhzVvM5Hp0K4A=; b=N34FJO3W6aX9Lq80QN9xhWLVYafEkNEe1Z2P0No7p3zljlwecO8sy509AyAFJnNrr9 P9GUZZ238u7H5sz2WFP/Nch7ewdeMtwmwOHF/uyCeZyi9BD93BelsolVnVK7ruidIZYZ +e6IEfugkV+FZdlzkkL9lcggsU7teLGFCF7GXM0R/JvRo3OGn4pUCkLXMhxbdg6U3lLr V/jvsPy5bl7jJZBvWH15E5y0QkU6XLNRiowUDWTnnWxSdNo5M/q+y1vGwmqW1DjNtMpS oKYz2qczdPLaN3O1/KQvQe0epOu9+iySv+qv1DbAeo1e0+/1IGgUgnm7qZQ9rygfIX6N m1pQ== X-Gm-Message-State: ALQs6tCyDPCFpsc0ERLhucBt26IB6X7uk4RMOcfV2hTf88gF8JcNCid7 etM2CB1dvMJ4LLQWjgJXlKhc2L04GwtH+p7rtExinpDamNa7MQS88ZaI489UiZobqE6KS43r6O4 /BRUp42JjzW3fsYVNLsJVEddHoUtqLTRNUlqT3WirTCzMQdXUTpEBczQw8Hgslbg= X-Google-Smtp-Source: AB8JxZq6ye3hfH1g/F4/TfrfJ5yQxxhe/MxyVVebe2aCbXG/5fn54G23e7vUFylSA6UOduJFVj1glXQ4H5gZGg== MIME-Version: 1.0 X-Received: by 2002:a81:3903:: with SMTP id g3-v6mr4518580ywa.54.1525901387802; Wed, 09 May 2018 14:29:47 -0700 (PDT) Date: Wed, 9 May 2018 14:29:35 -0700 In-Reply-To: <20180509205531.GD28451@char.us.oracle.com> Message-Id: <20180509212935.122395-1-jmattson@google.com> References: <20180509205531.GD28451@char.us.oracle.com> X-Mailer: git-send-email 2.17.0.441.gb46fe60e1d-goog Subject: [PATCH v2] kvm: x86: IA32_ARCH_CAPABILITIES is always supported From: Jim Mattson To: kvm@vger.kernel.org, karahmed@amazon.de, konrad.wilk@oracle.com, jmattson@google.com Cc: Jim Mattson Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If there is a possibility that a VM may migrate to a Skylake host, then the hypervisor should report IA32_ARCH_CAPABILITIES.RSBA[bit 2] as being set (future work, of course). This implies that CPUID.(EAX=7,ECX=0):EDX.ARCH_CAPABILITIES[bit 29] should be set. Therefore, kvm should report this CPUID bit as being supported whether or not the host supports it. Userspace is still free to clear the bit if it chooses. For more information on RSBA, see Intel's white paper, "Retpoline: A Branch Target Injection Mitigation" (Document Number 337131-001), currently available at https://bugzilla.kernel.org/show_bug.cgi?id=199511. Since the IA32_ARCH_CAPABILITIES MSR is emulated in kvm, there is no dependency on hardware support for this feature. Signed-off-by: Jim Mattson Reviewed-by: Konrad Rzeszutek Wilk --- arch/x86/kvm/cpuid.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c index 82055b90a8b3..beadfe6e6893 100644 --- a/arch/x86/kvm/cpuid.c +++ b/arch/x86/kvm/cpuid.c @@ -495,6 +495,11 @@ static inline int __do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function, entry->ecx &= ~F(PKU); entry->edx &= kvm_cpuid_7_0_edx_x86_features; cpuid_mask(&entry->edx, CPUID_7_EDX); + /* + * We emulate ARCH_CAPABILITIES in software even + * if the host doesn't support it. + */ + entry->edx |= F(ARCH_CAPABILITIES); } else { entry->ebx = 0; entry->ecx = 0;