From nobody Thu Apr 2 21:33:43 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C0646C6FA8B for ; Tue, 20 Sep 2022 20:59:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230346AbiITU7y (ORCPT ); Tue, 20 Sep 2022 16:59:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58040 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230112AbiITU7q (ORCPT ); Tue, 20 Sep 2022 16:59:46 -0400 Received: from mail-pj1-x104a.google.com (mail-pj1-x104a.google.com [IPv6:2607:f8b0:4864:20::104a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ADFEC13D08 for ; Tue, 20 Sep 2022 13:59:44 -0700 (PDT) Received: by mail-pj1-x104a.google.com with SMTP id il18-20020a17090b165200b002038e81ee7dso4496145pjb.4 for ; Tue, 20 Sep 2022 13:59:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date; bh=T7irDTPCqBENrbeucQrYstnxpwB8T+SjVIp8vtvhQwA=; b=VOU9LUxkejXMgsKC43w3F00oNRXpU12tfxO+lnX/U+JXWDYnV6Mf8Ps2Md4/hpVXy3 uKHoU+Rz72CPGUnuLqc0Vfi3Oi9UR504DzkAnSRahHsEFSogtFS4smGgwDKuH8IDSEZJ eq2sObUzPCwTb3WRfBfc0hKPqQguUvj8gf5P6XJi9d2uhveh4t1/KyUOroyEmqvIV6J+ OiHCbGIz9kfO/VQPQhlWecmCnXai61HqvvAgSnHZo/E7GCwxod14VUN2/SYQbbPbtzkx 4PoqFvULFTxTOm4UCG0knNHa6IhTeUDHLpRsQS8vSGN6JqtrevqEZzO98rb5+ZqDGeAM 7SzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date; bh=T7irDTPCqBENrbeucQrYstnxpwB8T+SjVIp8vtvhQwA=; b=ZE/LxrbcSJBtpLw/nQGFQ919FvEpmTji7Hk8TTI5l6bVCl2Uytj2Iab6b2lMOBNyyz 1674rE7u7ucOkqtYy0kzrEcTZmpSjJWiSs23p2oPfYTZtliF7xC/I5LKtOFn/X3ZOCmt 6OWtXcJ4F2MYjYvjBOz6NvDp863RgIGjTrV9tQQNKnPeFPNc6P/CB1pQgDslm9DFn6kE eldUDx4HwD8felgF7PS3cO/zxiy9dERbfKVlbMQfyU82nklZhaZmg5nWzftnb4N+AaSD 5hbGhHFauobOsT0CEQWz/QqQsRm6ep+EP0NeDpnezqQpImYaQJBn0+dNUzyJCW6/2+JL i1kw== X-Gm-Message-State: ACrzQf0kQxZVBpvux1pSnUGZpVLqAtpKk4nT2aFvtILk+rBDAsNd1dJN kRCAniQ8ZI0MrupbLOlT2pd1PvCPHhrfTw== X-Google-Smtp-Source: AMsMyM6JGqhEZn7j2eVRprmFD1uxxR2nVMfJ20xP/bVTPX+0A2/eAwy7d6kp2HO3A0anYKUHYmULd8y56ccYog== X-Received: from loggerhead.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:29a]) (user=jmattson job=sendgmr) by 2002:a62:17d1:0:b0:54d:87d5:249e with SMTP id 200-20020a6217d1000000b0054d87d5249emr15326219pfx.14.1663707584214; Tue, 20 Sep 2022 13:59:44 -0700 (PDT) Date: Tue, 20 Sep 2022 13:59:20 -0700 In-Reply-To: <20220920205922.1564814-1-jmattson@google.com> Mime-Version: 1.0 References: <20220920205922.1564814-1-jmattson@google.com> X-Mailer: git-send-email 2.37.3.968.ga6b4b080e4-goog Message-ID: <20220920205922.1564814-2-jmattson@google.com> Subject: [PATCH v2 1/3] Revert "KVM: SVM: Allow EFER.LMSLE to be set with nested svm" From: Jim Mattson To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H . Peter Anvin" , Sean Christopherson , Paolo Bonzini , linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: Jim Mattson Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Revert the hack that allowed a guest to set EFER.LMSLE, since no attempt was ever made to properly virtualize the feature. Now that AMD has deprecated the feature, the ROI for properly virtualizing it is vanishingly small. This reverts commit eec4b140c924b4c650e9a89e01d223266490e325. Fixes: eec4b140c924 ("KVM: SVM: Allow EFER.LMSLE to be set with nested svm") Signed-off-by: Jim Mattson --- arch/x86/include/asm/msr-index.h | 2 -- arch/x86/kvm/svm/svm.c | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-in= dex.h index 6674bdb096f3..0a0426f284a3 100644 --- a/arch/x86/include/asm/msr-index.h +++ b/arch/x86/include/asm/msr-index.h @@ -28,7 +28,6 @@ #define _EFER_LMA 10 /* Long mode active (read-only) */ #define _EFER_NX 11 /* No execute enable */ #define _EFER_SVME 12 /* Enable virtualization */ -#define _EFER_LMSLE 13 /* Long Mode Segment Limit Enable */ #define _EFER_FFXSR 14 /* Enable Fast FXSAVE/FXRSTOR */ =20 #define EFER_SCE (1<<_EFER_SCE) @@ -36,7 +35,6 @@ #define EFER_LMA (1<<_EFER_LMA) #define EFER_NX (1<<_EFER_NX) #define EFER_SVME (1<<_EFER_SVME) -#define EFER_LMSLE (1<<_EFER_LMSLE) #define EFER_FFXSR (1<<_EFER_FFXSR) =20 /* Intel MSRs. Some also available on other CPUs */ diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index f3813dbacb9f..3af360fe21e6 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -5012,7 +5012,7 @@ static __init int svm_hardware_setup(void) =20 if (nested) { printk(KERN_INFO "kvm: Nested Virtualization enabled\n"); - kvm_enable_efer_bits(EFER_SVME | EFER_LMSLE); + kvm_enable_efer_bits(EFER_SVME); } =20 /* --=20 2.37.3.968.ga6b4b080e4-goog From nobody Thu Apr 2 21:33:43 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D6AE8C54EE9 for ; Tue, 20 Sep 2022 21:00:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230366AbiITVAB (ORCPT ); Tue, 20 Sep 2022 17:00:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58196 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230272AbiITU7u (ORCPT ); Tue, 20 Sep 2022 16:59:50 -0400 Received: from mail-pj1-x1049.google.com (mail-pj1-x1049.google.com [IPv6:2607:f8b0:4864:20::1049]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 614001EEFD for ; Tue, 20 Sep 2022 13:59:46 -0700 (PDT) Received: by mail-pj1-x1049.google.com with SMTP id il18-20020a17090b165200b002038e81ee7dso4496183pjb.4 for ; Tue, 20 Sep 2022 13:59:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date; bh=S4qpE6/sC/2d5tmvyz+nC004gomHZT7yMkEkzcmn7Qs=; b=KV2g0Dz2GfX4x1uKEAkCQQa7hKSty51eB0dRokh3OTnSc0xKGaQhBCx1iIpBKg1PwU b4rsSl2/mCKYUGXMmkUjZaw1+cvIGFerbbJ750rAn2MM7c3WGfro3IwnMtNX0cq7NjiL KvijrB1cga2uRYOLcsWs0rXK//8D9fE9+UTxdo2cMQL6fa0YjVN90Lcqu9NPmvMQjoi0 JNT8hWnsTPC96bQUxfUOnNBvGzs2eiAR3O65iScnH2dQf4XSP7bPWqrMskd9KbAiQ0LS zoeDakCySvufbmFwbn0n5RGu2F5Ug+PPRLIZ4gIMdLrRSRVCHsDyi90XFxL0vgbYL6Rp Nj1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date; bh=S4qpE6/sC/2d5tmvyz+nC004gomHZT7yMkEkzcmn7Qs=; b=5GmgnP/djL2KDr2felcLawiMUCOVGls5ObnKiZg2LM+i8yGHUDl53U+2yubbNscNcu 0qE2ekSR83vhiQXp7rSUxg8vkEuYN1ryPzchmrE9rrRv+P7OQARAVyJtdVxBP0jGZVKx qBTQScWBbLGcFzC/iO6nMg0h950aylEyll+3gPPQFV9/ykhmch13VVRH+zB4APmUkWfQ ped+LTfYzLGOJ9ZB+YATahGBYL2vZhOxUargju8b/Sk3FIPawhsY9+kc+7q7/AJRxak1 tO9nm4Fo7oi17waxwy5/wexAPerBlpdHSbdNdXb7agR6bAUiII1jY9/jXhoeGqtGSjuS zShA== X-Gm-Message-State: ACrzQf3paXWu1bEMSaVl/mbG+fEpmfHo4EySbtCLZoZEwdWfIRvycAXw +3Q2GxmRD4ClWQ3PRHEhBueyE7j5TYGG+g== X-Google-Smtp-Source: AMsMyM4khVnbndZu+6w0/CQDpavnKKc4VO47ymIsUrhqLy7cu6/Jzmb1yK2mmcxqUEd1o0Kqll9ucz5Hd0gj8A== X-Received: from loggerhead.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:29a]) (user=jmattson job=sendgmr) by 2002:a05:6a00:1989:b0:546:410f:bdd2 with SMTP id d9-20020a056a00198900b00546410fbdd2mr25806289pfl.83.1663707585943; Tue, 20 Sep 2022 13:59:45 -0700 (PDT) Date: Tue, 20 Sep 2022 13:59:21 -0700 In-Reply-To: <20220920205922.1564814-1-jmattson@google.com> Mime-Version: 1.0 References: <20220920205922.1564814-1-jmattson@google.com> X-Mailer: git-send-email 2.37.3.968.ga6b4b080e4-goog Message-ID: <20220920205922.1564814-3-jmattson@google.com> Subject: [PATCH v2 2/3] x86/cpufeatures: Introduce X86_FEATURE_NO_LMSLE From: Jim Mattson To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H . Peter Anvin" , Sean Christopherson , Paolo Bonzini , linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: Jim Mattson Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When AMD introduced "Long Mode Segment Limit Enable" (a.k.a. "VMware mode"), the feature was not enumerated by a CPUID bit. Now that VMware has abandoned binary translation, AMD has deprecated EFER.LMSLE. The absence of the feature *is* now enumerated by a CPUID bit (a la Intel's X86_FEATURE_ZERO_FCS_DCS and X86_FEATURE_FDP_EXCPTN_ONLY). This defeature bit is already present in feature word 13, but it was previously anonymous. Name it X86_FEATURE_NO_LMSLE, so that KVM can reference it when constructing a supported guest CPUID table. Since this bit indicates the absence of a feature, don't enumerate it in /proc/cpuinfo. Signed-off-by: Jim Mattson Acked-by: Borislav Petkov --- arch/x86/include/asm/cpufeatures.h | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpuf= eatures.h index ef4775c6db01..0f5a3285d8d8 100644 --- a/arch/x86/include/asm/cpufeatures.h +++ b/arch/x86/include/asm/cpufeatures.h @@ -319,6 +319,7 @@ #define X86_FEATURE_AMD_IBRS (13*32+14) /* "" Indirect Branch Restricted = Speculation */ #define X86_FEATURE_AMD_STIBP (13*32+15) /* "" Single Thread Indirect Bra= nch Predictors */ #define X86_FEATURE_AMD_STIBP_ALWAYS_ON (13*32+17) /* "" Single Thread Ind= irect Branch Predictors always-on preferred */ +#define X86_FEATURE_NO_LMSLE (13*32+20) /* "" EFER_LMSLE is unsupported */ #define X86_FEATURE_AMD_PPIN (13*32+23) /* Protected Processor Inventory = Number */ #define X86_FEATURE_AMD_SSBD (13*32+24) /* "" Speculative Store Bypass Di= sable */ #define X86_FEATURE_VIRT_SSBD (13*32+25) /* Virtualized Speculative Store= Bypass Disable */ --=20 2.37.3.968.ga6b4b080e4-goog From nobody Thu Apr 2 21:33:43 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 576ACC54EE9 for ; Tue, 20 Sep 2022 21:00:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229512AbiITVAI (ORCPT ); Tue, 20 Sep 2022 17:00:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230236AbiITU7u (ORCPT ); Tue, 20 Sep 2022 16:59:50 -0400 Received: from mail-pg1-x54a.google.com (mail-pg1-x54a.google.com [IPv6:2607:f8b0:4864:20::54a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3650924F2F for ; Tue, 20 Sep 2022 13:59:48 -0700 (PDT) Received: by mail-pg1-x54a.google.com with SMTP id a12-20020a65604c000000b0042a8c1cc701so2276648pgp.1 for ; Tue, 20 Sep 2022 13:59:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date; bh=CtU5neKaHkcR+gqY0FDNg95nKTzPwcdnVlYYcQLqv5g=; b=UYZJTSuMWgBQGJVkNbAFEyDxsNpyBWKX9jfmgCGxoRLs7PKm+0eEZJGyY0mdAYQafd dC7CEpZdCc42AoQvxPOYoBTkb44cDre9QBj1E6VgTpo98rvF3EnnPpqkb0JdbAHo52Ah jFIZacTMz62sOB6yJfGJ49I0ih38iONGjiJMGAyGxzQxQ9ApdS6mp06S9xNclBShEF4L SB5HE3+0FOzwFG3hH1aF16oWc/YzHlpwEGVbqCCMygd5NKtcM8+quTQNUly8pj68M+Ms eFjdkFHnh0Fh77qc4k+Y880x5nAN0cTmDIaKIh+1IKqqqKLoTLvqHn192Ji7v5/HJ9Ba b6qQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date; bh=CtU5neKaHkcR+gqY0FDNg95nKTzPwcdnVlYYcQLqv5g=; b=XfPqHQQou0H/TvXshguxdgNFeBqo4J+nHxZpFbmmICNVnPl/Bec0LypjyA3+VO2f1Y bGJIzgsaBLnYRhkj0SgOE0eaZ6E59bvwwkACLoy59r4Z6FSFqRl+O+Yz/fBndVgVlx8e U2g8L9+wbLb1dqGoLk8jA7UoYtmWiidNUzlffMaXcT/gTGXN9DMy5olw3jh120fAoxDS 513/U/YCZHMTiZVmWu6smxZyVyh2n2zh+XEwOBwsnT02RwrR1sJrCkt3rXEwuBC7+qsA fEqU/QtNdp5t1Cv89wz2/XhWC0aJp370bMLCueTeY4b0FwXpdx1/wLVr6OzXU+9v4fUc V2zg== X-Gm-Message-State: ACrzQf07Xvm0f5oVo2nDvzsnmzpgFC2zxFWBld4tU1e5LWQMKmL0MZCM 9TacBUqgRiOlSKzJ/o6zRjpkxgk45MPfPA== X-Google-Smtp-Source: AMsMyM5sn0kmQvUal8aWjiFqlURJCVv+OEf2bD7ub022kJG8AKCl1w0qs18psU0JIpmC+qtnnJez34np53SDtw== X-Received: from loggerhead.c.googlers.com ([fda3:e722:ac3:cc00:24:72f4:c0a8:29a]) (user=jmattson job=sendgmr) by 2002:aa7:8892:0:b0:540:edcb:4773 with SMTP id z18-20020aa78892000000b00540edcb4773mr25226885pfe.19.1663707587772; Tue, 20 Sep 2022 13:59:47 -0700 (PDT) Date: Tue, 20 Sep 2022 13:59:22 -0700 In-Reply-To: <20220920205922.1564814-1-jmattson@google.com> Mime-Version: 1.0 References: <20220920205922.1564814-1-jmattson@google.com> X-Mailer: git-send-email 2.37.3.968.ga6b4b080e4-goog Message-ID: <20220920205922.1564814-4-jmattson@google.com> Subject: [PATCH v2 3/3] KVM: SVM: Unconditionally enumerate EferLmsleUnsupported From: Jim Mattson To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H . Peter Anvin" , Sean Christopherson , Paolo Bonzini , linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: Jim Mattson Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" CPUID.80000008H:EDX.EferLmsleUnsupported[bit 20] indicates that IA32_EFER.LMSLE[bit 13] is unsupported and must be zero. KVM doesn't support "Long Mode Segment Limit Enable," even if the underlying physical processor does, so set that bit in the guest CPUID table returned by KVM_GET_SUPPORTED_CPUID. Signed-off-by: Jim Mattson --- arch/x86/kvm/svm/svm.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index 3af360fe21e6..0bf6ac51f097 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -4945,6 +4945,7 @@ static __init void svm_set_cpu_caps(void) if (boot_cpu_has(X86_FEATURE_LS_CFG_SSBD) || boot_cpu_has(X86_FEATURE_AMD_SSBD)) kvm_cpu_cap_set(X86_FEATURE_VIRT_SSBD); + kvm_cpu_cap_set(X86_FEATURE_NO_LMSLE); =20 /* AMD PMU PERFCTR_CORE CPUID */ if (enable_pmu && boot_cpu_has(X86_FEATURE_PERFCTR_CORE)) --=20 2.37.3.968.ga6b4b080e4-goog