mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Melody Wang <huibo.wang@amd.com>
To: Tom Lendacky <thomas.lendacky@amd.com>
Cc: LKML <linux-kernel@vger.kernel.org>, x86@kernel.org
Subject: Re: [PATCH 2/7] x86/apic: Add an SVSM APIC driver
Date: Mon, 24 Aug 2026 19:06:53 -0700	[thread overview]
Message-ID: <8ada168a-2bff-4e9a-b0b3-6776b060f739@amd.com> (raw)
In-Reply-To: <a11dbf6d-e418-4372-a5ba-123f75243978@amd.com>

Hi Tom,

On 8/21/26 7:40 AM, Tom Lendacky wrote:

> If that is the case, then the fix would be to move the setting of the CAA
> into the svsm_perform_call_protocol() function and just make that function
> external, which will eliminate the need for svsm_do_call().
> 
> You would be a pre-patch then for fixing all the callers of
> svsm_perform_call_protocol().

This is the code, do you think this is what is in your mind?

diff --git a/arch/x86/coco/sev/svsm.c b/arch/x86/coco/sev/svsm.c
index e2d3bc3c26eb..f036a85a043b 100644
--- a/arch/x86/coco/sev/svsm.c
+++ b/arch/x86/coco/sev/svsm.c
@@ -74,6 +74,9 @@ int svsm_perform_call_protocol(struct svsm_call *call)

         flags = native_local_irq_save();

+       if (!call->caa)
+               call->caa = svsm_get_caa();
+
         ghcb = __sev_get_ghcb(&state);

         do {
@@ -87,6 +90,7 @@ int svsm_perform_call_protocol(struct svsm_call *call)

         return ret;
  }
+EXPORT_SYMBOL_GPL(svsm_perform_call_protocol);

  static u64 svsm_build_ca_from_pfn_range(u64 pfn, u64 pfn_end, bool action,
                                         struct svsm_pvalidate_call *pc)
@@ -321,7 +325,6 @@ int snp_svsm_vtpm_send_command(u8 *buffer)
  {
         struct svsm_call call = {};

-       call.caa = svsm_get_caa();
         call.rax = SVSM_VTPM_CALL(SVSM_VTPM_CMD);
         call.rcx = __pa(buffer);

@@ -345,7 +348,6 @@ bool snp_svsm_vtpm_probe(void)
         if (!snp_vmpl)
                 return false;

-       call.caa = svsm_get_caa();
         call.rax = SVSM_VTPM_CALL(SVSM_VTPM_QUERY);

         if (svsm_perform_call_protocol(&call))
@@ -354,9 +356,3 @@ bool snp_svsm_vtpm_probe(void)
         /* Check platform commands contains TPM_SEND_COMMAND - platform 
command 8 */
         return call.rcx_out & BIT_ULL(8);
  }
-
-int svsm_do_call(struct svsm_call *call)
-{
-       call->caa = svsm_get_caa();
-       return svsm_perform_call_protocol(call);
-}
diff --git a/arch/x86/include/asm/sev.h b/arch/x86/include/asm/sev.h
index f958f78e1db8..9013b392ad40 100644
--- a/arch/x86/include/asm/sev.h
+++ b/arch/x86/include/asm/sev.h
@@ -526,7 +526,6 @@ u64 sev_get_status(void);
  void sev_show_status(void);
  int prepare_pte_enc(struct pte_enc_desc *d);
  void set_pte_enc_mask(pte_t *kpte, unsigned long pfn, pgprot_t new_prot);
-int svsm_do_call(struct svsm_call *call);
  void snp_kexec_finish(void);
  void snp_kexec_begin(void);

@@ -536,7 +535,7 @@ void snp_msg_free(struct snp_msg_desc *mdesc);
  int snp_send_guest_request(struct snp_msg_desc *mdesc, struct 
snp_guest_req *req);

  int snp_svsm_vtpm_send_command(u8 *buffer);
-
+int svsm_perform_call_protocol(struct svsm_call *call);
  void __init snp_secure_tsc_prepare(void);
  void __init snp_secure_tsc_init(void);
  enum es_result savic_register_gpa(u64 gpa);
@@ -619,7 +618,6 @@ static inline int rmpadjust(unsigned long vaddr, 
bool rmp_psize, unsigned long a
  static inline void setup_ghcb(void) { }
  static inline void __init
  early_snp_set_memory_private(unsigned long vaddr, unsigned long paddr, 
unsigned long npages) { }
-static inline int svsm_do_call(struct svsm_call *call) { return 0; }
  static inline void __init
  early_snp_set_memory_shared(unsigned long vaddr, unsigned long paddr, 
unsigned long npages) { }
  static inline void snp_set_memory_shared(unsigned long vaddr, unsigned 
long npages) { }
@@ -645,6 +643,7 @@ static inline void snp_msg_free(struct snp_msg_desc 
*mdesc) { }
  static inline int snp_send_guest_request(struct snp_msg_desc *mdesc,
                                          struct snp_guest_req *req) { 
return -ENODEV; }
  static inline int snp_svsm_vtpm_send_command(u8 *buffer) { return 
-ENODEV; }
+static inline int svsm_perform_call_protocol(struct svsm_call *call) { 
return -ENODEV; }
  static inline void __init snp_secure_tsc_prepare(void) { }
  static inline void __init snp_secure_tsc_init(void) { }
  static inline void sev_evict_cache(void *va, int npages) {}

Thanks,
Melody

> 
> Thanks,
> Tom
> 
>>
> 

-- 
Thanks,
Melody


  reply	other threads:[~2026-08-25  2:06 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-30  1:48 [PATCH 0/7] Alternate Injection: Secure Interrupt Delivery for SEV-SNP Guests - Guest Support Melody Wang
2026-07-30  1:48 ` [PATCH 1/7] x86/sev: Add support for Alternate Injection Melody Wang
2026-07-31 15:27   ` Tom Lendacky
2026-07-30  1:48 ` [PATCH 2/7] x86/apic: Add an SVSM APIC driver Melody Wang
2026-07-31 17:39   ` Tom Lendacky
2026-08-20  5:06     ` Melody Wang
2026-08-20 15:43       ` Tom Lendacky
2026-08-21  3:19         ` Melody Wang
2026-08-21 14:40           ` Tom Lendacky
2026-08-25  2:06             ` Melody Wang [this message]
2026-07-30  1:48 ` [PATCH 3/7] x86/sev: Allow the guest to configure interrupt vectors for the hypervisor Melody Wang
2026-07-31 17:52   ` Tom Lendacky
2026-07-30  1:48 ` [PATCH 4/7] x86/sev: Route unsupported APIC register accesses to the hypervisor APIC emulation Melody Wang
2026-07-31 18:37   ` Tom Lendacky
2026-07-30  1:48 ` [PATCH 5/7] x86/sev: Add a function to contain all SEV-specific setup operations Melody Wang
2026-07-31 19:15   ` Tom Lendacky
2026-07-30  1:48 ` [PATCH 6/7] x86/sev: Register the guest with the SVSM APIC protocol Melody Wang
2026-07-31 19:18   ` Tom Lendacky
2026-07-30  1:48 ` [PATCH 7/7] x86/sev: Indicate that Alternate Injection is supported in the guest Melody Wang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8ada168a-2bff-4e9a-b0b3-6776b060f739@amd.com \
    --to=huibo.wang@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=thomas.lendacky@amd.com \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®