Skip to content

Commit 672162a

Browse files
committed
Merge tag 'kvm-x86-svm-6.14' of https://github.com/kvm-x86/linux into HEAD
KVM SVM changes for 6.14: - Macrofy the SEV=n version of the sev_xxx_guest() helpers so that the code is optimized away when building with less than brilliant compilers. - Remove a now-redundant TLB flush when guest CR4.PGE changes. - Use str_enabled_disabled() to replace open coded strings.
2 parents cae083c + 4c334c6 commit 672162a

File tree

3 files changed

+9
-20
lines changed

3 files changed

+9
-20
lines changed

arch/x86/kvm/svm/sev.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3051,11 +3051,11 @@ void __init sev_hardware_setup(void)
30513051
min_sev_asid, max_sev_asid);
30523052
if (boot_cpu_has(X86_FEATURE_SEV_ES))
30533053
pr_info("SEV-ES %s (ASIDs %u - %u)\n",
3054-
sev_es_supported ? "enabled" : "disabled",
3054+
str_enabled_disabled(sev_es_supported),
30553055
min_sev_asid > 1 ? 1 : 0, min_sev_asid - 1);
30563056
if (boot_cpu_has(X86_FEATURE_SEV_SNP))
30573057
pr_info("SEV-SNP %s (ASIDs %u - %u)\n",
3058-
sev_snp_supported ? "enabled" : "disabled",
3058+
str_enabled_disabled(sev_snp_supported),
30593059
min_sev_asid > 1 ? 1 : 0, min_sev_asid - 1);
30603060

30613061
sev_enabled = sev_supported;

arch/x86/kvm/svm/svm.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include <linux/rwsem.h>
2929
#include <linux/cc_platform.h>
3030
#include <linux/smp.h>
31+
#include <linux/string_choices.h>
3132

3233
#include <asm/apic.h>
3334
#include <asm/perf_event.h>
@@ -284,8 +285,6 @@ u32 svm_msrpm_offset(u32 msr)
284285
return MSR_INVALID;
285286
}
286287

287-
static void svm_flush_tlb_current(struct kvm_vcpu *vcpu);
288-
289288
static int get_npt_level(void)
290289
{
291290
#ifdef CONFIG_X86_64
@@ -1921,9 +1920,6 @@ void svm_set_cr4(struct kvm_vcpu *vcpu, unsigned long cr4)
19211920
unsigned long host_cr4_mce = cr4_read_shadow() & X86_CR4_MCE;
19221921
unsigned long old_cr4 = vcpu->arch.cr4;
19231922

1924-
if (npt_enabled && ((old_cr4 ^ cr4) & X86_CR4_PGE))
1925-
svm_flush_tlb_current(vcpu);
1926-
19271923
vcpu->arch.cr4 = cr4;
19281924
if (!npt_enabled) {
19291925
cr4 |= X86_CR4_PAE;
@@ -5328,7 +5324,7 @@ static __init int svm_hardware_setup(void)
53285324
/* Force VM NPT level equal to the host's paging level */
53295325
kvm_configure_mmu(npt_enabled, get_npt_level(),
53305326
get_npt_level(), PG_LEVEL_1G);
5331-
pr_info("Nested Paging %sabled\n", npt_enabled ? "en" : "dis");
5327+
pr_info("Nested Paging %s\n", str_enabled_disabled(npt_enabled));
53325328

53335329
/* Setup shadow_me_value and shadow_me_mask */
53345330
kvm_mmu_set_me_spte_mask(sme_me_mask, sme_me_mask);

arch/x86/kvm/svm/svm.h

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -358,39 +358,32 @@ static __always_inline struct kvm_sev_info *to_kvm_sev_info(struct kvm *kvm)
358358
return &to_kvm_svm(kvm)->sev_info;
359359
}
360360

361+
#ifdef CONFIG_KVM_AMD_SEV
361362
static __always_inline bool sev_guest(struct kvm *kvm)
362363
{
363-
#ifdef CONFIG_KVM_AMD_SEV
364364
struct kvm_sev_info *sev = &to_kvm_svm(kvm)->sev_info;
365365

366366
return sev->active;
367-
#else
368-
return false;
369-
#endif
370367
}
371-
372368
static __always_inline bool sev_es_guest(struct kvm *kvm)
373369
{
374-
#ifdef CONFIG_KVM_AMD_SEV
375370
struct kvm_sev_info *sev = &to_kvm_svm(kvm)->sev_info;
376371

377372
return sev->es_active && !WARN_ON_ONCE(!sev->active);
378-
#else
379-
return false;
380-
#endif
381373
}
382374

383375
static __always_inline bool sev_snp_guest(struct kvm *kvm)
384376
{
385-
#ifdef CONFIG_KVM_AMD_SEV
386377
struct kvm_sev_info *sev = &to_kvm_svm(kvm)->sev_info;
387378

388379
return (sev->vmsa_features & SVM_SEV_FEAT_SNP_ACTIVE) &&
389380
!WARN_ON_ONCE(!sev_es_guest(kvm));
381+
}
390382
#else
391-
return false;
383+
#define sev_guest(kvm) false
384+
#define sev_es_guest(kvm) false
385+
#define sev_snp_guest(kvm) false
392386
#endif
393-
}
394387

395388
static inline bool ghcb_gpa_is_registered(struct vcpu_svm *svm, u64 val)
396389
{

0 commit comments

Comments
 (0)