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

Re: [PATCH v4 3/3] amd/msr: implement VIRT_SPEC_CTRL for HVM guests using legacy SSBD


  • To: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Mon, 2 May 2022 08:13:49 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=C6SrEPP0E+ZtWJrOeWA0W0GiswQNM23vVzM/o5CocNw=; b=T8u2wwBjUbyKzdEPKNDNcDiAXZebt9zoAhm3UqaXrZ4rWqdcXDAe3SY7llm5PPZCAvht+GWQ8ZjtlPSl/xMCDmvO88PcYTVTe8/5r6infLMbJ4q4ZoUpf1p9U3yGOUCbzwOGxAmQxOw//aTxIvFGHnZQul0Q4jXqDPktOboz3nv0AH+lEDZ8LZKhyA+X0UNIsthmSy694RsgR8A7WLUB0jPXPOCM/zb6kp3sgZSg7187HFVby8EiUR2XKbj8WYc+iBJoIzjeW9orYHF1PKUncmqozDtdq2cSpstWoUs2FbZWQ8jmGHPOgTGGrWYMqPt4U0TmtWvIWN2Rw3smqsR3BA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FnXxes3LU+panu5urfx36bEHYprXnMzxI0eDlBhwqUDIFHGJ0kbVrwxj+YVZs5UbAR9h7WF++vKpx4eZkZjmhwizDSjKGlJBFhXa3sz2GcUy7YPmKIlMwRftWhbtBrmAyT3Rmc7yAeboN7SKQ6mYQVODoQjgVbFs0kQwUQ5b4fd6agqBi8dwpBbJ8bkwT9qdHo2kR88cFW4z9wkQn0uUXOp5X3MyI0kRYPVO6NHUn1tHSOjGotL/daqlRicNswvHlgVNINIzvd4/ZYCXtiqEA/OIEwKUBdit57NkYVk9enchpBkpLXiFZuyr8CY+qpLzIppeoxmnlmR5/maaMBTCMQ==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Mon, 02 May 2022 06:14:00 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 29.04.2022 18:11, Roger Pau Monné wrote:
> On Fri, Apr 29, 2022 at 05:49:42PM +0200, Roger Pau Monné wrote:
>> On Fri, Apr 29, 2022 at 12:59:58PM +0200, Jan Beulich wrote:
>>> On 27.04.2022 12:47, Roger Pau Monne wrote:
>>>> +void amd_set_legacy_ssbd(bool enable)
>>>> +{
>>>> +  const struct cpuinfo_x86 *c = &current_cpu_data;
>>>> +  struct ssbd_ls_cfg *status;
>>>> +
>>>> +  if (c->x86 != 0x17 || c->x86_num_siblings <= 1) {
>>>> +          BUG_ON(!set_legacy_ssbd(c, enable));
>>>> +          return;
>>>> +  }
>>>> +
>>>> +  BUG_ON(c->phys_proc_id >= AMD_FAM17H_MAX_SOCKETS);
>>>> +  BUG_ON(c->cpu_core_id >= ssbd_max_cores);
>>>> +  status = &ssbd_ls_cfg[c->phys_proc_id * ssbd_max_cores +
>>>> +                        c->cpu_core_id];
>>>> +
>>>> +  /*
>>>> +   * Open code a very simple spinlock: this function is used with GIF==0
>>>> +   * and different IF values, so would trigger the checklock detector.
>>>> +   * Instead of trying to workaround the detector, use a very simple lock
>>>> +   * implementation: it's better to reduce the amount of code executed
>>>> +   * with GIF==0.
>>>> +   */
>>>> +  while ( test_and_set_bool(status->locked) )
>>>> +      cpu_relax();
>>>> +  status->count += enable ? 1 : -1;
>>>> +  ASSERT(status->count <= c->x86_num_siblings);
>>>> +  if (enable ? status->count == 1 : !status->count)
>>>> +          BUG_ON(!set_legacy_ssbd(c, enable));
>>>
>>> What are the effects of ASSERT() or BUG_ON() triggering in a GIF=0
>>> region?
>>
>> So AFAICT the BUG itself works, the usage of a crash kernel however
>> won't work as it's booted with GIF==0.
>>
>> Maybe we need to issue an stgi as part of BUG_FRAME if required?
>> (maybe that's too naive...)
> 
> Well, better in panic() or kexec_crash() likely.

Yeah, lifting it too early may be detrimental.

Jan




 


Rackspace

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