From nobody Thu Apr 2 18:28:39 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 183D0C6FA8E for ; Wed, 21 Sep 2022 20:16:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230488AbiIUUQS (ORCPT ); Wed, 21 Sep 2022 16:16:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35844 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230380AbiIUUQO (ORCPT ); Wed, 21 Sep 2022 16:16:14 -0400 Received: from mail-pg1-x549.google.com (mail-pg1-x549.google.com [IPv6:2607:f8b0:4864:20::549]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D642A9CCF4 for ; Wed, 21 Sep 2022 13:16:11 -0700 (PDT) Received: by mail-pg1-x549.google.com with SMTP id m188-20020a633fc5000000b00434dccacd4aso4020851pga.10 for ; Wed, 21 Sep 2022 13:16:11 -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:reply-to:from:to:cc:subject:date; bh=85AbQQlrxSyNOvkklUzdnLL8SyGBcXrNMjiPdjNbViM=; b=GRc1XP6pFfXy+MKZXSkWMWzT1GELN5Jwabnv/SNslVgH962Xpspgo2fYtTGD0wD1yO EyDnc2Iv8VL1SoB8JGww4seaGNzIiBGtGJqoEhn0/65bfykOoJr1AqSl9cwPSjHF4gBG 9BT3JzcOSNTQYZ+EulPuwyqOdBLoRsUsD0iWuGQLzB3RslV8e1ku2UbmzEOs4ddC6jbo kwM2kdb7P0yFMuASjfoCnlNLOHjHhlEkAvncZI346xaZBoDAHc9Sefwl3j/AnJ3rxFs1 eLY6FCz8ZRiHCXxP4cRVO6OWSGPra020qJUeYughUtf5Pko4ioaDFSo1epv/kfT1VBAQ a1gg== 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:reply-to:x-gm-message-state:from:to:cc:subject:date; bh=85AbQQlrxSyNOvkklUzdnLL8SyGBcXrNMjiPdjNbViM=; b=JK7KvuAk51luiUhMRjycdkCPA/IS+HfuQcM8cIX4ZGj9q6DuO0aScVke7gzyhEK8/v C+QJJgh+/6GXXat1htqcg4zTGBHTpQCdFpyDRTmhX+7PCzEpTEOCHaNRj0ZIoHCfKw07 XYJUgrNZ5e2yF7HEht/OI56H/eCTyfm0cGg7CvoVbFMZo8/LnrF4YU7ms3QgzNtcpAFM z/1s8e4dHQu5aiItkcuSAvvFjjS6CTXHA2LLzNRDsjIIkRtf+jk/C9p/EdmXbcn74j14 Fv8BjbVbewV9GSGxqY7/LgNduvxzkHveXQeDMQUVYzQHJ/ypgZ/Woj8KDKdTKIK3stgj hRZg== X-Gm-Message-State: ACrzQf2x8zzGJjciBesRmOF4dR/QzY46dy5iEIbuTH+pNTSyieVugKLz 2UxMo8yyRUHirGqsFjxKwcuZitau8Yo= X-Google-Smtp-Source: AMsMyM5I2QA6CA+YVRl4Wf7yGB3m1KxYD3Hht8hY5ewEgA+2X6rfKd57lWaEKou7/sOuvb39Yu776+rxPGY= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a05:6a00:2402:b0:52c:81cf:8df2 with SMTP id z2-20020a056a00240200b0052c81cf8df2mr30477098pfh.40.1663791370910; Wed, 21 Sep 2022 13:16:10 -0700 (PDT) Reply-To: Sean Christopherson Date: Wed, 21 Sep 2022 20:16:04 +0000 In-Reply-To: <20220921201607.3156750-1-seanjc@google.com> Mime-Version: 1.0 References: <20220921201607.3156750-1-seanjc@google.com> X-Mailer: git-send-email 2.37.3.968.ga6b4b080e4-goog Message-ID: <20220921201607.3156750-2-seanjc@google.com> Subject: [PATCH 1/4] x86/hyperv: Move VMCB enlightenment definitions to hyperv-tlfs.h From: Sean Christopherson To: "K. Y. Srinivasan" , Haiyang Zhang , Stephen Hemminger , Wei Liu , Dexuan Cui , Sean Christopherson , Paolo Bonzini , Vitaly Kuznetsov Cc: linux-hyperv@vger.kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Move Hyper-V's VMCB enlightenment definitions to the TLFS header; the definitions come directly from the TLFS[*], not from KVM. No functional change intended. [*] https://learn.microsoft.com/en-us/virtualization/hyper-v-on-windows/tlf= s/datatypes/hv_svm_enlightened_vmcb_fields Signed-off-by: Sean Christopherson --- arch/x86/include/asm/hyperv-tlfs.h | 22 +++++++++++++++++++ arch/x86/kvm/svm/hyperv.h | 35 ------------------------------ arch/x86/kvm/svm/svm_onhyperv.h | 3 ++- 3 files changed, 24 insertions(+), 36 deletions(-) delete mode 100644 arch/x86/kvm/svm/hyperv.h diff --git a/arch/x86/include/asm/hyperv-tlfs.h b/arch/x86/include/asm/hype= rv-tlfs.h index 0a9407dc0859..4c4f81daf5a2 100644 --- a/arch/x86/include/asm/hyperv-tlfs.h +++ b/arch/x86/include/asm/hyperv-tlfs.h @@ -584,6 +584,28 @@ struct hv_enlightened_vmcs { =20 #define HV_VMX_ENLIGHTENED_CLEAN_FIELD_ALL 0xFFFF =20 +/* + * Hyper-V uses the software reserved 32 bytes in VMCB control area to exp= ose + * SVM enlightenments to guests. + */ +struct hv_enlightenments { + struct __packed hv_enlightenments_control { + u32 nested_flush_hypercall:1; + u32 msr_bitmap:1; + u32 enlightened_npt_tlb: 1; + u32 reserved:29; + } __packed hv_enlightenments_control; + u32 hv_vp_id; + u64 hv_vm_id; + u64 partition_assist_page; + u64 reserved; +} __packed; + +/* + * Hyper-V uses the software reserved clean bit in VMCB. + */ +#define VMCB_HV_NESTED_ENLIGHTENMENTS 31 + struct hv_partition_assist_pg { u32 tlb_lock_count; }; diff --git a/arch/x86/kvm/svm/hyperv.h b/arch/x86/kvm/svm/hyperv.h deleted file mode 100644 index 7d6d97968fb9..000000000000 --- a/arch/x86/kvm/svm/hyperv.h +++ /dev/null @@ -1,35 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ -/* - * Common Hyper-V on KVM and KVM on Hyper-V definitions (SVM). - */ - -#ifndef __ARCH_X86_KVM_SVM_HYPERV_H__ -#define __ARCH_X86_KVM_SVM_HYPERV_H__ - -#include - -#include "../hyperv.h" - -/* - * Hyper-V uses the software reserved 32 bytes in VMCB - * control area to expose SVM enlightenments to guests. - */ -struct hv_enlightenments { - struct __packed hv_enlightenments_control { - u32 nested_flush_hypercall:1; - u32 msr_bitmap:1; - u32 enlightened_npt_tlb: 1; - u32 reserved:29; - } __packed hv_enlightenments_control; - u32 hv_vp_id; - u64 hv_vm_id; - u64 partition_assist_page; - u64 reserved; -} __packed; - -/* - * Hyper-V uses the software reserved clean bit in VMCB - */ -#define VMCB_HV_NESTED_ENLIGHTENMENTS VMCB_SW - -#endif /* __ARCH_X86_KVM_SVM_HYPERV_H__ */ diff --git a/arch/x86/kvm/svm/svm_onhyperv.h b/arch/x86/kvm/svm/svm_onhyper= v.h index e2fc59380465..8d02654ad6f8 100644 --- a/arch/x86/kvm/svm/svm_onhyperv.h +++ b/arch/x86/kvm/svm/svm_onhyperv.h @@ -8,8 +8,9 @@ =20 #if IS_ENABLED(CONFIG_HYPERV) =20 +#include + #include "kvm_onhyperv.h" -#include "svm/hyperv.h" =20 static struct kvm_x86_ops svm_x86_ops; =20 --=20 2.37.3.968.ga6b4b080e4-goog From nobody Thu Apr 2 18:28:39 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 2C212C6FA8B for ; Wed, 21 Sep 2022 20:16:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230476AbiIUUQ0 (ORCPT ); Wed, 21 Sep 2022 16:16:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35890 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230475AbiIUUQQ (ORCPT ); Wed, 21 Sep 2022 16:16:16 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E897A4B0F for ; Wed, 21 Sep 2022 13:16:14 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id bu13-20020a056902090d00b00671743601f1so6193787ybb.0 for ; Wed, 21 Sep 2022 13:16:14 -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:reply-to:from:to:cc:subject:date; bh=9UwbrQ0jbfkdWibvQjcC8zTWLX7OGdH/X8ruvlS1WMg=; b=d6OxGnQwB6PfvAxP09aDlfsT7F+vltfemklLt+BdEo9n3HeF5TNxtuhbxj95cNx1OX 4YGu4iYzkQN5Ev8cwMJSQ5djfM0aw7Zw94hSpNKrxRfotDdC0JTQWVUJy23fYusp5S5X B2PGbCjiSWD1+qdythdWEj2fHw7RFJnUVJewsM+/yYxUVpQAljsB+LJXxUXbFxMyE8sl whhTLh+BC5S5B3avSV8SuylbxXaiDiSVFrEwImHUcTnHEU+cGdeCZe1x4u4tiILhKll0 7y5FUfiRtE4tOIXhUj2vd8/+vIPN6TPW/O8sk3U2l0JFvs2J4KU2hzO30G+IfuB+yGE+ 1y1g== 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:reply-to:x-gm-message-state:from:to:cc:subject:date; bh=9UwbrQ0jbfkdWibvQjcC8zTWLX7OGdH/X8ruvlS1WMg=; b=SudK4mfFuAq2/6TXPFSE3uAKygwkydW7vOAfmBGpy0+12jTHZMSEoTt2C4faHS0NkB kbdLJ44fUfdlAzu2BPxCkQs+Cm6GBQTMTEA42gHeU30bBsXH5NJt47CV1uWrpXVXHFfg WVFKLASkdxRLo8qN9ZJqSMj6niJYWJG9gfRkY6crir7EFAV/lJxORGN+eeI4Osv9TmvY 8nUEFpkBqCUbhzH4cnvtzj6ysDcCPsbkKSNBoWSVwyxI7sAlMQ5pJlNqiYRXvbGqOTyF ygQT5gYApKF/HC+51rLMuJmxYGc1bk+xDBxqhzssrVbirJEQfEX1CGAcq5vZ4DV+61tf UmWw== X-Gm-Message-State: ACrzQf3OSdnTZ9h9JTcERIgEcbxqoamDO9AcSZ+eAciuNH7xhyyl/7W4 kIDA6y95xwldHd3okz+ewbCS527F1Fs= X-Google-Smtp-Source: AMsMyM5oooDD0bapnTTsN91Ujsfq/81cDKDLq8MhjvmiTpwq+/VM4sHbdG7LLT/W813IB7Q5fZK3VMMV1bU= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a25:2187:0:b0:6b0:1abc:2027 with SMTP id h129-20020a252187000000b006b01abc2027mr110766ybh.348.1663791372853; Wed, 21 Sep 2022 13:16:12 -0700 (PDT) Reply-To: Sean Christopherson Date: Wed, 21 Sep 2022 20:16:05 +0000 In-Reply-To: <20220921201607.3156750-1-seanjc@google.com> Mime-Version: 1.0 References: <20220921201607.3156750-1-seanjc@google.com> X-Mailer: git-send-email 2.37.3.968.ga6b4b080e4-goog Message-ID: <20220921201607.3156750-3-seanjc@google.com> Subject: [PATCH 2/4] KVM: selftests: Move "struct hv_enlightenments" to x86_64/svm.h From: Sean Christopherson To: "K. Y. Srinivasan" , Haiyang Zhang , Stephen Hemminger , Wei Liu , Dexuan Cui , Sean Christopherson , Paolo Bonzini , Vitaly Kuznetsov Cc: linux-hyperv@vger.kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Move Hyper-V's VMCB "struct hv_enlightenments" to the svm.h header so that the struct can be referenced in "struct vmcb_control_area". Alternatively, a dedicated header for SVM+Hyper-V could be added, a la x86_64/evmcs.h, but it doesn't appear that Hyper-V will end up needing a wholesale replacement for the VMCB. No functional change intended. Signed-off-by: Sean Christopherson --- .../testing/selftests/kvm/include/x86_64/svm.h | 17 +++++++++++++++++ .../selftests/kvm/x86_64/hyperv_svm_test.c | 18 ------------------ 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/tools/testing/selftests/kvm/include/x86_64/svm.h b/tools/testi= ng/selftests/kvm/include/x86_64/svm.h index c8343ff84f7f..10b9d0d4e0ec 100644 --- a/tools/testing/selftests/kvm/include/x86_64/svm.h +++ b/tools/testing/selftests/kvm/include/x86_64/svm.h @@ -58,6 +58,23 @@ enum { INTERCEPT_RDPRU, }; =20 +struct hv_enlightenments { + struct __packed hv_enlightenments_control { + u32 nested_flush_hypercall:1; + u32 msr_bitmap:1; + u32 enlightened_npt_tlb: 1; + u32 reserved:29; + } __packed hv_enlightenments_control; + u32 hv_vp_id; + u64 hv_vm_id; + u64 partition_assist_page; + u64 reserved; +} __packed; + +/* + * Hyper-V uses the software reserved clean bit in VMCB + */ +#define VMCB_HV_NESTED_ENLIGHTENMENTS (1U << 31) =20 struct __attribute__ ((__packed__)) vmcb_control_area { u32 intercept_cr; diff --git a/tools/testing/selftests/kvm/x86_64/hyperv_svm_test.c b/tools/t= esting/selftests/kvm/x86_64/hyperv_svm_test.c index a380ad7bb9b3..b366b197759f 100644 --- a/tools/testing/selftests/kvm/x86_64/hyperv_svm_test.c +++ b/tools/testing/selftests/kvm/x86_64/hyperv_svm_test.c @@ -23,24 +23,6 @@ =20 #define L2_GUEST_STACK_SIZE 256 =20 -struct hv_enlightenments { - struct __packed hv_enlightenments_control { - u32 nested_flush_hypercall:1; - u32 msr_bitmap:1; - u32 enlightened_npt_tlb: 1; - u32 reserved:29; - } __packed hv_enlightenments_control; - u32 hv_vp_id; - u64 hv_vm_id; - u64 partition_assist_page; - u64 reserved; -} __packed; - -/* - * Hyper-V uses the software reserved clean bit in VMCB - */ -#define VMCB_HV_NESTED_ENLIGHTENMENTS (1U << 31) - void l2_guest_code(void) { GUEST_SYNC(3); --=20 2.37.3.968.ga6b4b080e4-goog From nobody Thu Apr 2 18:28:39 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 4BD35ECAAD8 for ; Wed, 21 Sep 2022 20:16:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231161AbiIUUQa (ORCPT ); Wed, 21 Sep 2022 16:16:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230466AbiIUUQR (ORCPT ); Wed, 21 Sep 2022 16:16:17 -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 1D100A1A54 for ; Wed, 21 Sep 2022 13:16:14 -0700 (PDT) Received: by mail-pj1-x104a.google.com with SMTP id x1-20020a17090a8a8100b00200a805fba9so9038105pjn.7 for ; Wed, 21 Sep 2022 13:16:14 -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:reply-to:from:to:cc:subject:date; bh=gADxGD3M+iWlkeq6JJoA+zipD9oPqMfH/FDJZbo9W8k=; b=dYJhkoXFX6b09AesK77GzgwjsJP150V80OHAJ8ei1sYqvUFapGXol5fi5V/hKIqMr6 PYlucJZqSS18InQIlMZUVDAxyNhdjgumX6DUM5daD6mxqxi4exTGVvx+5s55YmzDYwl9 XPZC3EvSQzavcTt9UWfqD3Q+c28BXoXfPvCps2kSTH/5cq6e7A5OMu3TFI9mkBwQF6Wh Vhw8nmDaijp1zPmYgm81t5/kZ28+8JXhxCvQGAGId/3F5hgALR+fvCT5ARGp2rY4rO4r XkhmTLbeT/P5Sey2XIrHiMf8EUAUOmhKeUPS7ke+5RoKPcoUGhv54GBPNXDUj2BCvpf5 PbcQ== 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:reply-to:x-gm-message-state:from:to:cc:subject:date; bh=gADxGD3M+iWlkeq6JJoA+zipD9oPqMfH/FDJZbo9W8k=; b=P7kIuNH6FYm2+7s21cb4VaWfspgM1yCjb7SDi9+ZlhbBsl5wKZApQeM6+qYj/h5CAz hJy/U2UxIAumsd0txKzlwjGQyaqEQOXZNeYz64jKull6f67Y7VdE2L6z7mfzcatfpPL3 BWMTTjonb3ojjJP0SrgfCHd4T6HkAEW2rJWGLaVF9PBa+l5CtSOiGfWCUITpuBLAtgdD XcV3tBYb7Ji9Q0l1kmeSAHhGWVadBbUhMironEXC4vR49jRDVzObKjvmmoYOqjetULRU d3+O+MbbkI8r7htsYYB5f5OWYJ3M3nb9mdqbYi8hZbXTc79TrnJ+EQMJNaJVnSNUjeoZ f0sw== X-Gm-Message-State: ACrzQf3+feb+PGdPoQwAipePuEBzgf66e14QiHDnK5yf8QY7eE7wceLR iSeknD2jraR2RK1qcyXji+7eMUTbs10= X-Google-Smtp-Source: AMsMyM7F3SVf5CZTUMNETS+vKu7ldPw6wGwZamZOlHlXMP4FGTeESf4cAMADtfuimHIlsvqvdbg+qJqH/cY= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a05:6a00:2187:b0:541:ca61:48b7 with SMTP id h7-20020a056a00218700b00541ca6148b7mr30562304pfi.83.1663791374328; Wed, 21 Sep 2022 13:16:14 -0700 (PDT) Reply-To: Sean Christopherson Date: Wed, 21 Sep 2022 20:16:06 +0000 In-Reply-To: <20220921201607.3156750-1-seanjc@google.com> Mime-Version: 1.0 References: <20220921201607.3156750-1-seanjc@google.com> X-Mailer: git-send-email 2.37.3.968.ga6b4b080e4-goog Message-ID: <20220921201607.3156750-4-seanjc@google.com> Subject: [PATCH 3/4] KVM: SVM: Add a proper field for Hyper-V VMCB enlightenments From: Sean Christopherson To: "K. Y. Srinivasan" , Haiyang Zhang , Stephen Hemminger , Wei Liu , Dexuan Cui , Sean Christopherson , Paolo Bonzini , Vitaly Kuznetsov Cc: linux-hyperv@vger.kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add a union to provide hv_enlightenments side-by-side with the sw_reserved bytes that Hyper-V's enlightenments overlay. Casting sw_reserved everywhere is messy, confusing, and unnecessarily unsafe. No functional change intended. Signed-off-by: Sean Christopherson --- arch/x86/include/asm/svm.h | 7 ++++++- arch/x86/kvm/svm/nested.c | 9 ++++----- arch/x86/kvm/svm/svm.h | 5 ++++- arch/x86/kvm/svm/svm_onhyperv.c | 2 +- arch/x86/kvm/svm/svm_onhyperv.h | 15 +++++++-------- tools/testing/selftests/kvm/include/x86_64/svm.h | 5 ++++- .../selftests/kvm/x86_64/hyperv_svm_test.c | 3 +-- 7 files changed, 27 insertions(+), 19 deletions(-) diff --git a/arch/x86/include/asm/svm.h b/arch/x86/include/asm/svm.h index 0361626841bc..6befed2b30a6 100644 --- a/arch/x86/include/asm/svm.h +++ b/arch/x86/include/asm/svm.h @@ -5,6 +5,8 @@ #include #include =20 +#include + /* * 32-bit intercept words in the VMCB Control Area, starting * at Byte offset 000h. @@ -161,7 +163,10 @@ struct __attribute__ ((__packed__)) vmcb_control_area { * Offset 0x3e0, 32 bytes reserved * for use by hypervisor/software. */ - u8 reserved_sw[32]; + union { + struct hv_enlightenments hv_enlightenments; + u8 reserved_sw[32]; + }; }; =20 =20 diff --git a/arch/x86/kvm/svm/nested.c b/arch/x86/kvm/svm/nested.c index 76dcc8a3e849..a6a87d9743ce 100644 --- a/arch/x86/kvm/svm/nested.c +++ b/arch/x86/kvm/svm/nested.c @@ -201,8 +201,7 @@ void recalc_intercepts(struct vcpu_svm *svm) */ static bool nested_svm_vmrun_msrpm(struct vcpu_svm *svm) { - struct hv_enlightenments *hve =3D - (struct hv_enlightenments *)svm->nested.ctl.reserved_sw; + struct hv_enlightenments *hve =3D &svm->nested.ctl.hv_enlightenments; int i; =20 /* @@ -391,8 +390,8 @@ void __nested_copy_vmcb_control_to_cache(struct kvm_vcp= u *vcpu, /* Hyper-V extensions (Enlightened VMCB) */ if (kvm_hv_hypercall_enabled(vcpu)) { to->clean =3D from->clean; - memcpy(to->reserved_sw, from->reserved_sw, - sizeof(struct hv_enlightenments)); + memcpy(&to->hv_enlightenments, &from->hv_enlightenments, + sizeof(to->hv_enlightenments)); } } =20 @@ -1485,7 +1484,7 @@ static void nested_copy_vmcb_cache_to_control(struct = vmcb_control_area *dst, dst->virt_ext =3D from->virt_ext; dst->pause_filter_count =3D from->pause_filter_count; dst->pause_filter_thresh =3D from->pause_filter_thresh; - /* 'clean' and 'reserved_sw' are not changed by KVM */ + /* 'clean' and 'hv_enlightenments' are not changed by KVM */ } =20 static int svm_get_nested_state(struct kvm_vcpu *vcpu, diff --git a/arch/x86/kvm/svm/svm.h b/arch/x86/kvm/svm/svm.h index 6a7686bf6900..9eb2fc76732f 100644 --- a/arch/x86/kvm/svm/svm.h +++ b/arch/x86/kvm/svm/svm.h @@ -151,7 +151,10 @@ struct vmcb_ctrl_area_cached { u64 nested_cr3; u64 virt_ext; u32 clean; - u8 reserved_sw[32]; + union { + struct hv_enlightenments hv_enlightenments; + u8 reserved_sw[32]; + }; }; =20 struct svm_nested_state { diff --git a/arch/x86/kvm/svm/svm_onhyperv.c b/arch/x86/kvm/svm/svm_onhyper= v.c index 8cdc62c74a96..5d4036611a37 100644 --- a/arch/x86/kvm/svm/svm_onhyperv.c +++ b/arch/x86/kvm/svm/svm_onhyperv.c @@ -26,7 +26,7 @@ int svm_hv_enable_direct_tlbflush(struct kvm_vcpu *vcpu) if (!*p_hv_pa_pg) return -ENOMEM; =20 - hve =3D (struct hv_enlightenments *)to_svm(vcpu)->vmcb->control.reserved_= sw; + hve =3D &to_svm(vcpu)->vmcb->control.hv_enlightenments; =20 hve->partition_assist_page =3D __pa(*p_hv_pa_pg); hve->hv_vm_id =3D (unsigned long)vcpu->kvm; diff --git a/arch/x86/kvm/svm/svm_onhyperv.h b/arch/x86/kvm/svm/svm_onhyper= v.h index 8d02654ad6f8..c8f8045305be 100644 --- a/arch/x86/kvm/svm/svm_onhyperv.h +++ b/arch/x86/kvm/svm/svm_onhyperv.h @@ -18,8 +18,10 @@ int svm_hv_enable_direct_tlbflush(struct kvm_vcpu *vcpu); =20 static inline void svm_hv_init_vmcb(struct vmcb *vmcb) { - struct hv_enlightenments *hve =3D - (struct hv_enlightenments *)vmcb->control.reserved_sw; + struct hv_enlightenments *hve =3D &vmcb->control.hv_enlightenments; + + BUILD_BUG_ON(sizeof(vmcb->control.hv_enlightenments) !=3D + sizeof(vmcb->control.reserved_sw)); =20 if (npt_enabled && ms_hyperv.nested_features & HV_X64_NESTED_ENLIGHTENED_TLB) @@ -61,18 +63,15 @@ static inline void svm_hv_vmcb_dirty_nested_enlightenme= nts( struct kvm_vcpu *vcpu) { struct vmcb *vmcb =3D to_svm(vcpu)->vmcb; - struct hv_enlightenments *hve =3D - (struct hv_enlightenments *)vmcb->control.reserved_sw; + struct hv_enlightenments *hve =3D &vmcb->control.hv_enlightenments; =20 if (hve->hv_enlightenments_control.msr_bitmap) vmcb_mark_dirty(vmcb, VMCB_HV_NESTED_ENLIGHTENMENTS); } =20 -static inline void svm_hv_update_vp_id(struct vmcb *vmcb, - struct kvm_vcpu *vcpu) +static inline void svm_hv_update_vp_id(struct vmcb *vmcb, struct kvm_vcpu = *vcpu) { - struct hv_enlightenments *hve =3D - (struct hv_enlightenments *)vmcb->control.reserved_sw; + struct hv_enlightenments *hve =3D &vmcb->control.hv_enlightenments; u32 vp_index =3D kvm_hv_get_vpindex(vcpu); =20 if (hve->hv_vp_id !=3D vp_index) { diff --git a/tools/testing/selftests/kvm/include/x86_64/svm.h b/tools/testi= ng/selftests/kvm/include/x86_64/svm.h index 10b9d0d4e0ec..0c32549c6b64 100644 --- a/tools/testing/selftests/kvm/include/x86_64/svm.h +++ b/tools/testing/selftests/kvm/include/x86_64/svm.h @@ -123,7 +123,10 @@ struct __attribute__ ((__packed__)) vmcb_control_area { * Offset 0x3e0, 32 bytes reserved * for use by hypervisor/software. */ - u8 reserved_sw[32]; + union { + struct hv_enlightenments hv_enlightenments; + u8 reserved_sw[32]; + }; }; =20 =20 diff --git a/tools/testing/selftests/kvm/x86_64/hyperv_svm_test.c b/tools/t= esting/selftests/kvm/x86_64/hyperv_svm_test.c index b366b197759f..81b204ee509a 100644 --- a/tools/testing/selftests/kvm/x86_64/hyperv_svm_test.c +++ b/tools/testing/selftests/kvm/x86_64/hyperv_svm_test.c @@ -46,8 +46,7 @@ static void __attribute__((__flatten__)) guest_code(struc= t svm_test_data *svm) { unsigned long l2_guest_stack[L2_GUEST_STACK_SIZE]; struct vmcb *vmcb =3D svm->vmcb; - struct hv_enlightenments *hve =3D - (struct hv_enlightenments *)vmcb->control.reserved_sw; + struct hv_enlightenments *hve =3D &vmcb->control.hv_enlightenments; =20 GUEST_SYNC(1); =20 --=20 2.37.3.968.ga6b4b080e4-goog From nobody Thu Apr 2 18:28:39 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 60A04C6FA82 for ; Wed, 21 Sep 2022 20:16:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231194AbiIUUQf (ORCPT ); Wed, 21 Sep 2022 16:16:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230500AbiIUUQT (ORCPT ); Wed, 21 Sep 2022 16:16:19 -0400 Received: from mail-pl1-x649.google.com (mail-pl1-x649.google.com [IPv6:2607:f8b0:4864:20::649]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E7399E0F5 for ; Wed, 21 Sep 2022 13:16:16 -0700 (PDT) Received: by mail-pl1-x649.google.com with SMTP id x13-20020a170902ec8d00b00177f0fa642cso4517585plg.10 for ; Wed, 21 Sep 2022 13:16:16 -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:reply-to:from:to:cc:subject:date; bh=lpyPWQxXRZTNHwtFSxl2dSmKDyXDF3+wOW3rgKVQSqU=; b=FZjzOxu686KYJiTxPDOZC2FoprduGFjXZkXWBmtmref8jEQABYD+cTHV1X1j/wWRWk hEQjTfY5iwgk88XSmO8/WJuulmqUMG0b1kY/372bTTh7psaWGjaCV5FAm68KMWeqeprh YYe0MxR2J34t4bJcatTbx0+97HHnaF2R6zAW9QQzKr6okqkMkkHmFqohMNXNy5BgY6nR 9TgYAfld3a60ADIeg8m/rfFi8pJwLVoExi7GgJdY8v3pqSHNqzGB1H+P8ZdJBOVlxdmT 2pKCEHWCpgX7FlFr325mNTY25Si/+X2Ir2lKhZEafAtvD6rw4W84QKkQ8bayeoovRnm9 MIVw== 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:reply-to:x-gm-message-state:from:to:cc:subject:date; bh=lpyPWQxXRZTNHwtFSxl2dSmKDyXDF3+wOW3rgKVQSqU=; b=f0bBBBJUolW1zTM6k4RfRK8L8MYkY8hNAW8/eh6H/5XkuTPa7NDMDk4xWEbWOkvUPM 0PnI04BwCFE/JSwUv1AHNFmeVA7gwnxU6n1WO8ErSTHNF6ZqgXIoyiNpgRtan5C++pyH RyQVDiJHsYhkQtfFhUtF43ZeR781qiLNaapzAqFM5mGfHY9oIRW73TYm3fe0VAeuiJe+ 3Z/zS1OBtveCjULtQyyJhipyyICK46U2B60gw+Dmkg/UH6meuuAfEIRe/Cc8b4HHH6UO L+Vvt01x/28pHqy+jLJhHiPDf3FjNrdHifxPH1ZqiLVBxRx/cyy6xAW4R1GgV+KjSIBg Xsig== X-Gm-Message-State: ACrzQf0RISk7pdWzqrEETv1HGhI4EXSmXZBHk40S0O7eHgaNOg9ld/+D 3GfGkxzgxXPsxBXZuQ6IBa+NJIjBesk= X-Google-Smtp-Source: AMsMyM7sKDV6zZ24NK8ohlR4v+6+rr8Xi2VEFhgNFa6ouqqjOS4ISAUDxFK+iWxhRL/DvQOZDBQvFFt8S+k= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a17:90b:3144:b0:202:e2cd:2d2a with SMTP id ip4-20020a17090b314400b00202e2cd2d2amr11288766pjb.39.1663791376230; Wed, 21 Sep 2022 13:16:16 -0700 (PDT) Reply-To: Sean Christopherson Date: Wed, 21 Sep 2022 20:16:07 +0000 In-Reply-To: <20220921201607.3156750-1-seanjc@google.com> Mime-Version: 1.0 References: <20220921201607.3156750-1-seanjc@google.com> X-Mailer: git-send-email 2.37.3.968.ga6b4b080e4-goog Message-ID: <20220921201607.3156750-5-seanjc@google.com> Subject: [PATCH 4/4] x86/hyperv: KVM: Rename "hv_enlightenments" to "hv_vmcb_enlightenments" From: Sean Christopherson To: "K. Y. Srinivasan" , Haiyang Zhang , Stephen Hemminger , Wei Liu , Dexuan Cui , Sean Christopherson , Paolo Bonzini , Vitaly Kuznetsov Cc: linux-hyperv@vger.kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Now that KVM isn't littered with "struct hv_enlightenments" casts, rename the struct to "hv_vmcb_enlightenments" to highlight the fact that the struct is specifically for SVM's VMCB. No functional change intended. Signed-off-by: Sean Christopherson Reviewed-by: Michael Kelley --- arch/x86/include/asm/hyperv-tlfs.h | 2 +- arch/x86/include/asm/svm.h | 2 +- arch/x86/kvm/svm/nested.c | 2 +- arch/x86/kvm/svm/svm.h | 2 +- arch/x86/kvm/svm/svm_onhyperv.c | 2 +- arch/x86/kvm/svm/svm_onhyperv.h | 6 +++--- tools/testing/selftests/kvm/include/x86_64/svm.h | 4 ++-- tools/testing/selftests/kvm/x86_64/hyperv_svm_test.c | 2 +- 8 files changed, 11 insertions(+), 11 deletions(-) diff --git a/arch/x86/include/asm/hyperv-tlfs.h b/arch/x86/include/asm/hype= rv-tlfs.h index 4c4f81daf5a2..f7a431bcb2c3 100644 --- a/arch/x86/include/asm/hyperv-tlfs.h +++ b/arch/x86/include/asm/hyperv-tlfs.h @@ -588,7 +588,7 @@ struct hv_enlightened_vmcs { * Hyper-V uses the software reserved 32 bytes in VMCB control area to exp= ose * SVM enlightenments to guests. */ -struct hv_enlightenments { +struct hv_vmcb_enlightenments { struct __packed hv_enlightenments_control { u32 nested_flush_hypercall:1; u32 msr_bitmap:1; diff --git a/arch/x86/include/asm/svm.h b/arch/x86/include/asm/svm.h index 6befed2b30a6..621f064bb7cc 100644 --- a/arch/x86/include/asm/svm.h +++ b/arch/x86/include/asm/svm.h @@ -164,7 +164,7 @@ struct __attribute__ ((__packed__)) vmcb_control_area { * for use by hypervisor/software. */ union { - struct hv_enlightenments hv_enlightenments; + struct hv_vmcb_enlightenments hv_enlightenments; u8 reserved_sw[32]; }; }; diff --git a/arch/x86/kvm/svm/nested.c b/arch/x86/kvm/svm/nested.c index a6a87d9743ce..bc9fb4dbf0ae 100644 --- a/arch/x86/kvm/svm/nested.c +++ b/arch/x86/kvm/svm/nested.c @@ -201,7 +201,7 @@ void recalc_intercepts(struct vcpu_svm *svm) */ static bool nested_svm_vmrun_msrpm(struct vcpu_svm *svm) { - struct hv_enlightenments *hve =3D &svm->nested.ctl.hv_enlightenments; + struct hv_vmcb_enlightenments *hve =3D &svm->nested.ctl.hv_enlightenments; int i; =20 /* diff --git a/arch/x86/kvm/svm/svm.h b/arch/x86/kvm/svm/svm.h index 9eb2fc76732f..5e1178bc9a64 100644 --- a/arch/x86/kvm/svm/svm.h +++ b/arch/x86/kvm/svm/svm.h @@ -152,7 +152,7 @@ struct vmcb_ctrl_area_cached { u64 virt_ext; u32 clean; union { - struct hv_enlightenments hv_enlightenments; + struct hv_vmcb_enlightenments hv_enlightenments; u8 reserved_sw[32]; }; }; diff --git a/arch/x86/kvm/svm/svm_onhyperv.c b/arch/x86/kvm/svm/svm_onhyper= v.c index 5d4036611a37..0b657c7cd21b 100644 --- a/arch/x86/kvm/svm/svm_onhyperv.c +++ b/arch/x86/kvm/svm/svm_onhyperv.c @@ -16,7 +16,7 @@ =20 int svm_hv_enable_direct_tlbflush(struct kvm_vcpu *vcpu) { - struct hv_enlightenments *hve; + struct hv_vmcb_enlightenments *hve; struct hv_partition_assist_pg **p_hv_pa_pg =3D &to_kvm_hv(vcpu->kvm)->hv_pa_pg; =20 diff --git a/arch/x86/kvm/svm/svm_onhyperv.h b/arch/x86/kvm/svm/svm_onhyper= v.h index c8f8045305be..e08cd7192559 100644 --- a/arch/x86/kvm/svm/svm_onhyperv.h +++ b/arch/x86/kvm/svm/svm_onhyperv.h @@ -18,7 +18,7 @@ int svm_hv_enable_direct_tlbflush(struct kvm_vcpu *vcpu); =20 static inline void svm_hv_init_vmcb(struct vmcb *vmcb) { - struct hv_enlightenments *hve =3D &vmcb->control.hv_enlightenments; + struct hv_vmcb_enlightenments *hve =3D &vmcb->control.hv_enlightenments; =20 BUILD_BUG_ON(sizeof(vmcb->control.hv_enlightenments) !=3D sizeof(vmcb->control.reserved_sw)); @@ -63,7 +63,7 @@ static inline void svm_hv_vmcb_dirty_nested_enlightenment= s( struct kvm_vcpu *vcpu) { struct vmcb *vmcb =3D to_svm(vcpu)->vmcb; - struct hv_enlightenments *hve =3D &vmcb->control.hv_enlightenments; + struct hv_vmcb_enlightenments *hve =3D &vmcb->control.hv_enlightenments; =20 if (hve->hv_enlightenments_control.msr_bitmap) vmcb_mark_dirty(vmcb, VMCB_HV_NESTED_ENLIGHTENMENTS); @@ -71,7 +71,7 @@ static inline void svm_hv_vmcb_dirty_nested_enlightenment= s( =20 static inline void svm_hv_update_vp_id(struct vmcb *vmcb, struct kvm_vcpu = *vcpu) { - struct hv_enlightenments *hve =3D &vmcb->control.hv_enlightenments; + struct hv_vmcb_enlightenments *hve =3D &vmcb->control.hv_enlightenments; u32 vp_index =3D kvm_hv_get_vpindex(vcpu); =20 if (hve->hv_vp_id !=3D vp_index) { diff --git a/tools/testing/selftests/kvm/include/x86_64/svm.h b/tools/testi= ng/selftests/kvm/include/x86_64/svm.h index 0c32549c6b64..49292190c219 100644 --- a/tools/testing/selftests/kvm/include/x86_64/svm.h +++ b/tools/testing/selftests/kvm/include/x86_64/svm.h @@ -58,7 +58,7 @@ enum { INTERCEPT_RDPRU, }; =20 -struct hv_enlightenments { +struct hv_vmcb_enlightenments { struct __packed hv_enlightenments_control { u32 nested_flush_hypercall:1; u32 msr_bitmap:1; @@ -124,7 +124,7 @@ struct __attribute__ ((__packed__)) vmcb_control_area { * for use by hypervisor/software. */ union { - struct hv_enlightenments hv_enlightenments; + struct hv_vmcb_enlightenments hv_enlightenments; u8 reserved_sw[32]; }; }; diff --git a/tools/testing/selftests/kvm/x86_64/hyperv_svm_test.c b/tools/t= esting/selftests/kvm/x86_64/hyperv_svm_test.c index 81b204ee509a..f8e43c798c86 100644 --- a/tools/testing/selftests/kvm/x86_64/hyperv_svm_test.c +++ b/tools/testing/selftests/kvm/x86_64/hyperv_svm_test.c @@ -46,7 +46,7 @@ static void __attribute__((__flatten__)) guest_code(struc= t svm_test_data *svm) { unsigned long l2_guest_stack[L2_GUEST_STACK_SIZE]; struct vmcb *vmcb =3D svm->vmcb; - struct hv_enlightenments *hve =3D &vmcb->control.hv_enlightenments; + struct hv_vmcb_enlightenments *hve =3D &vmcb->control.hv_enlightenments; =20 GUEST_SYNC(1); =20 --=20 2.37.3.968.ga6b4b080e4-goog