[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 2/2] x86/svm: Intercept Bus Locks for HVM guests


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Date: Tue, 20 Jan 2026 13:29:49 +0000
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=c3KrVPRaIiECjYbYSaGxk2ViYhhaRcd18ddTvf/i5ko=; b=wizV+IlqfLslykvbRpH2DMwe/wTVkAwEpq1apKCVDIACG7Kb6ggk334tQVRj84i3N3/lyUdE7HqSCyWVC2f9Gn9HCe/LP3wUIG8zNksTnS40DMwVgdwnvhtH6so/uFm5XXpAKhg4wDkfLyblcqIlf8S9kRorS4sovhkPNy0OlWl9QdHOC05whx1lpOvS1SpgLNgl2fD86ATRf1TBrPDx0iEVCKFfg+tNIKOyGLnIhfdk4nwAo+5wos4+jkpRk+pALawyWjZXZdXCR7Ruy6yIoopd88J9qekLQsf847VsuYj7Qid0aRpUu17WNmCQxQIeNaNO2ZdBMKaagcCIRHn8RQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=qDpmRyx658HqU2LHnhPkEc15jkUVrFkywiqJl3ZbzMssHbnF0B3w08DJesCIA8mgRiCye2duMbkGMSbjpBScGktqg85kcp3PJqBckxuRYrbQPQPNz7QvtbMyLWZUHDU0CXFw+UPToT+dmOaRdQuLrml6FIJ5JK1ejZwANU6Kzf9+FdRc46LW50a/cRCgyZCKUTeG6THoI6LWaO3ORARfg1m79RtGjeeoXcpLMpv78JHMC473gcE7HwtcNDIVRUbe9gQs+4eRDvR2c3G1bqzGPa8noxk49+UNcy142PFw0sbtaE09Hu4sXJIcE21R+C1RMLFVqfv4LwWpV3UlWL04ew==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Jason Andryuk <jason.andryuk@xxxxxxx>, Alejandro Vallejo <alejandro.garciavallejo@xxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx, Stefano Stabellini <sstabellini@xxxxxxxxxx>
  • Delivery-date: Tue, 20 Jan 2026 13:29:58 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 20/01/2026 1:27 pm, Jan Beulich wrote:
> On 20.01.2026 14:18, Andrew Cooper wrote:
>> On 20/01/2026 9:53 am, Alejandro Vallejo wrote:
>>> --- a/xen/arch/x86/hvm/svm/vmcb.c
>>> +++ b/xen/arch/x86/hvm/svm/vmcb.c
>>> @@ -66,6 +66,12 @@ static int construct_vmcb(struct vcpu *v)
>>>          GENERAL2_INTERCEPT_XSETBV      | GENERAL2_INTERCEPT_ICEBP       |
>>>          GENERAL2_INTERCEPT_RDPRU;
>>>  
>>> +    if ( cpu_has_bus_lock_thresh )
>>> +    {
>>> +        vmcb->_general3_intercepts = GENERAL3_INTERCEPT_BUS_LOCK_THRESH;
>> |=
>>
>>> +        vmcb->bus_lock_thresh = 1; /* trigger immediately */
>> Really?  The APM states:
>>
>> On processors that support Bus Lock Threshold (indicated by CPUID
>> Fn8000_000A_EDX[29] BusLockThreshold=1), the VMCB provides a Bus Lock
>> Threshold enable bit and an unsigned 16-bit Bus Lock Threshold count. On
>> VMRUN, this value is loaded into an internal count register. Before the
>> processor executes a bus lock in the guest, it checks the value of this
>> register. If the value is greater than 0, the processor executes the bus
>> lock successfully and decrements the count. If the value is 0, the bus
>> lock is not executed and a #VMEXIT to the VMM is taken.
>>
>> So according to the APM, setting the count to 1 will permit one bus lock
>> then exit (fault style) immediately before the next.  This also says
>> that a count of 0 is a legal state.
> But then you'd livelock the guest as soon as it uses a bus lock. Are you
> suggesting to set to 1 in response to a bus lock exit, and keep at 0 at
> all other times?

I should have been clearer.  I'm complaining at the "trigger
immediately" comment, because I don't think that's a correct statement
of how hardware behaves.

Simply dropping the comment would be ok, but I'd also like to understand
hardware behaviour if it differs from what the APM says.

~Andrew



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.