<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Aptos;}
@font-face
        {font-family:Georgia;
        panose-1:2 4 5 2 5 4 5 2 3 3;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        font-size:12.0pt;
        font-family:"Aptos",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#467886;
        text-decoration:underline;}
span.EmailStyle21
        {mso-style-type:personal-reply;
        font-family:"Georgia",serif;
        color:blue;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;
        mso-ligatures:none;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="#467886" vlink="#96607D" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Georgia",serif;color:blue">David, thanks for clearing up the architectural behavior.  I agree with what you say below about how to decide when VMPL 0 should be invoked.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Georgia",serif;color:blue"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Georgia",serif;color:blue">-Jon<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Georgia",serif;color:blue"><o:p> </o:p></span></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">From:</span></b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"> Kaplan, David <David.Kaplan@amd.com>
<br>
<b>Sent:</b> Tuesday, April 15, 2025 5:49 PM<br>
<b>To:</b> Jon Lange <jlange@microsoft.com>; Wang, Huibo <Huibo.Wang@amd.com>; svsm-devel@coconut-svsm.dev<br>
<b>Cc:</b> Lendacky, Thomas <Thomas.Lendacky@amd.com><br>
<b>Subject:</b> [EXTERNAL] RE: Clear the guest busy bit when Alternated Injection is enabled<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p style="margin:5.0pt"><span style="font-size:10.0pt;font-family:"Calibri",sans-serif;color:blue">[AMD Official Use Only - AMD Internal Distribution Only]<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Arial",sans-serif">What I said below is wrong, please ignore it.  If the HV attempts to run a busy (or invalid) VMSA, it will update the exit code info in the *<b>VMCB</b>* but not the *<b>VMSA</b>*. 
 So the error information in the VMSA does not get lost.  It looks like I mis-interpreted some logs, apologies for the confusion.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Arial",sans-serif"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Arial",sans-serif">That said, it will still be more efficient if the HV looks at EXITINTINFO.V to know to invoke VMPL0 rather than waiting for VMEXIT_BUSY.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Arial",sans-serif"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Arial",sans-serif">--David Kaplan<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Arial",sans-serif"><o:p> </o:p></span></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt">
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">From:</span></b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"> Kaplan, David
<br>
<b>Sent:</b> Tuesday, April 15, 2025 10:59 AM<br>
<b>To:</b> Jon Lange <<a href="mailto:jlange@microsoft.com">jlange@microsoft.com</a>>; Wang, Huibo <<a href="mailto:Huibo.Wang@amd.com">Huibo.Wang@amd.com</a>>;
<a href="mailto:svsm-devel@coconut-svsm.dev">svsm-devel@coconut-svsm.dev</a><br>
<b>Cc:</b> Lendacky, Thomas <<a href="mailto:Thomas.Lendacky@amd.com">Thomas.Lendacky@amd.com</a>><br>
<b>Subject:</b> RE: Clear the guest busy bit when Alternated Injection is enabled<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Arial",sans-serif">The HV cannot wait until it sees a VMEXIT_BUSY because then the error information about what caused the busy bit to get set becomes lost (the original error gets overwritten
 in the guest VMSA).  I think Melody’s point is that if the HV sees EXITINTINFO.V=1 then it should know that the busy bit got set and invoke VMPL0 which may need to re-inject the event that caused the exit.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Arial",sans-serif"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Arial",sans-serif">I don’t think the HV necessarily needs to tell the SVSM to clear the guest busy bit, that seems like something the SVSM itself should check.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Arial",sans-serif"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Arial",sans-serif">--David Kaplan<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Arial",sans-serif"><o:p> </o:p></span></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt">
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">From:</span></b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"> Jon Lange <<a href="mailto:jlange@microsoft.com">jlange@microsoft.com</a>>
<br>
<b>Sent:</b> Tuesday, April 15, 2025 10:36 AM<br>
<b>To:</b> Wang, Huibo <<a href="mailto:Huibo.Wang@amd.com">Huibo.Wang@amd.com</a>>;
<a href="mailto:svsm-devel@coconut-svsm.dev">svsm-devel@coconut-svsm.dev</a><br>
<b>Cc:</b> Lendacky, Thomas <<a href="mailto:Thomas.Lendacky@amd.com">Thomas.Lendacky@amd.com</a>>; Kaplan, David <<a href="mailto:David.Kaplan@amd.com">David.Kaplan@amd.com</a>><br>
<b>Subject:</b> RE: Clear the guest busy bit when Alternated Injection is enabled<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p style="margin:5.0pt"><span style="font-size:10.0pt;font-family:"Calibri",sans-serif;color:blue">[AMD Official Use Only - AMD Internal Distribution Only]<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<table class="MsoNormalTable" border="0" cellspacing="0" cellpadding="0" align="left" width="100%" style="width:100.0%">
<tbody>
<tr>
<td style="background:#FFB900;padding:5.0pt 2.0pt 5.0pt 2.0pt"></td>
<td width="100%" style="width:100.0%;background:#FFF8E5;padding:5.0pt 4.0pt 5.0pt 12.0pt">
<div>
<p class="MsoNormal" style="mso-element:frame;mso-element-frame-hspace:2.25pt;mso-element-wrap:around;mso-element-anchor-vertical:paragraph;mso-element-anchor-horizontal:column;mso-height-rule:exactly">
<b><span style="color:#222222">Caution:</span></b><span style="color:#222222"> This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
<o:p></o:p></span></p>
</div>
</td>
</tr>
</tbody>
</table>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Georgia",serif;color:blue">The SVSM should always be clearing the busy bit when it decides that it is safe to reenter the guest.  There should be no hypervisor control of when and how this happens. 
 If the hypervisor encounters a busy bit error, it should invoke the SVSM, which should take the correct action to return the guest to a runnable state (or should panic if it detects that a fatal error prevents the guest from being runnable again).<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Georgia",serif;color:blue"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Georgia",serif;color:blue">-Jon<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Georgia",serif;color:blue"><o:p> </o:p></span></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">From:</span></b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"> Wang, Huibo <<a href="mailto:Huibo.Wang@amd.com">Huibo.Wang@amd.com</a>>
<br>
<b>Sent:</b> Tuesday, April 15, 2025 8:17 AM<br>
<b>To:</b> <a href="mailto:svsm-devel@coconut-svsm.dev">svsm-devel@coconut-svsm.dev</a><br>
<b>Cc:</b> Jon Lange <<a href="mailto:jlange@microsoft.com">jlange@microsoft.com</a>>; Lendacky, Thomas <<a href="mailto:Thomas.Lendacky@amd.com">Thomas.Lendacky@amd.com</a>>; Kaplan, David <<a href="mailto:David.Kaplan@amd.com">David.Kaplan@amd.com</a>><br>
<b>Subject:</b> [EXTERNAL] Clear the guest busy bit when Alternated Injection is enabled<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p style="margin:5.0pt"><span style="font-size:10.0pt;font-family:"Calibri",sans-serif;color:blue">[AMD Official Use Only - AMD Internal Distribution Only]<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal"><span style="color:black">Hi,<br>
<br>
I am currently working towards enabling Alternate Injection in Linux and Coconut SVSM.<br>
<br>
When I start a guest, I hit a KVM internal error - VMEXIT_BUSY.  In guests that run with Alternate Injection, bit 63 of the encrypted VIntrCtrl field is defined as a BUSY bit. On VMRUN, if VIntrCtrl[BUSY] is set to 1, then the VMRUN fails with a VMEXIT_BUSY
 error code. The BUSY bit enables a VMSA to be temporarily marked non-runnable while software modifications are in progress.<br>
<br>
When KVM is trying to deliver an interrupt or exception into the guest while a VMEXIT happens, then the busy bit gets set in the guest's VMSA. So VMPL0 needs to come in a re-inject the event to the guest.<br>
<br>
To solve this problem, the HV should not wait for VMEXIT_BUSY.  If it sees that EXITINTINFO.V=1 on an exit and Alternate Injection is enabled, it should invoke VMPL0 to clear the busy bit and then ask to switch to run the guest which will keep running the interrupted
 interrupt/exception.<br>
<br>
The question is how would we like the communication between HV and SVSM to look like when it comes to the HV letting the SVSM know that the guest's busy bit needs to get cleared before it runs again? <br>
<br>
For example, should the HV explicitly set something in the HVDB page indicating that the SVSM should clear its guest's busy bit or should the SVSM itself always check the busy bit before running the guest and clear it if set?<br>
<br>
Or any other, better idea?<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="color:black"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="color:black">Thanks,<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="color:black">Melody<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="color:black"><o:p> </o:p></span></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>