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

Re: [PATCH v6] x86: detect CMOS aliasing on ports other than 0x70/0x71


  • To: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Thu, 20 Apr 2023 16:55:32 +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=wThXQbyC/G5eLouaVldG04k+jzCpyz3zziIZopr+s4I=; b=CmN869umJQbv81gaDjW6UNnbTlVcOqIgDx7/1DJptviPxekr1UH8HOpuNDnm/2xKbI7VJ3wEjHsCE19RgoljYnrhOBrVVx+LehTzAxJy19r38yjPM6HdHdRdO2BhSG7CvazMKDUe+91WSw22ZeCgzsdSVLhR481msxhXXFPVGHDOk0J+c0gIDNJ6YWqk63beuToS55J9kLzI9283aiEgSbS1FYX4INfYiaeFR4GL2jmM4WOU4hTyhWUWVq6JWc8YhDTl2dUfHNNkIVlpkQLh7l2Ea7ftFk0z5FsY8OnHS1QWZw0tQIDWLVN/uiZ/v9wFtzWuUrTcLESJYTMsvBlbvg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UvouuGhvgUd/qvo8vsfAkA6dQV8T+MZDc6Jq4mMA8d2pAUj5mSPog8kaADb6/+WGDasaFSS9d6oBla3jEUlRw/but3cie4meXUqV2QC6rksHaWQBjEtq9YuAT7AvGVOHoNuAHCnp2eH3swmUnPOnAeFklGTo+XNJ1qBnLwh53jC71eCAVgyy1rx4krOH5ZZw0HBMvgWWykCvERsSOLFX+xc6tkEEkMdOLuXenhC5DdQH7Vbnzqvr44sYHuvp8z9T5eMpa0XZJ86isOCc0gtJr5jHB+U6Pud6bQxaWR+TTXn8m1aafW31LAENNoBFQ8L173rbPD7zK3bdaezNISd7bQ==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Paul Durrant <paul@xxxxxxx>, Wei Liu <wl@xxxxxxx>
  • Delivery-date: Thu, 20 Apr 2023 14:55:51 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 20.04.2023 16:31, Roger Pau Monné wrote:
> On Thu, Apr 20, 2023 at 10:31:08AM +0200, Jan Beulich wrote:
>> On 19.04.2023 17:55, Roger Pau Monné wrote:
>>> On Wed, Apr 19, 2023 at 03:58:10PM +0200, Jan Beulich wrote:
>>>> @@ -1342,6 +1349,17 @@ unsigned int rtc_guest_read(unsigned int
>>>>           * underlying hardware would permit doing so.
>>>>           */
>>>>          data = currd->arch.cmos_idx & (0xff >> (port == RTC_PORT(0)));
>>>> +
>>>> +        /*
>>>> +         * When there's (supposedly) no RTC/CMOS, we don't intercept the 
>>>> other
>>>> +         * ports. While reading the index register isn't normally 
>>>> possible,
>>>> +         * play safe and return back whatever can be read (just in case a 
>>>> value
>>>> +         * written through an alias would be attempted to be read back 
>>>> here).
>>>> +         */
>>>> +        if ( port == RTC_PORT(0) &&
>>>> +             (acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_CMOS_RTC) &&
>>>> +             ioports_access_permitted(currd, port, port) )
>>>> +            data = inb(port) & 0x7f;
>>>
>>> Do we really need to mask the high bit here?  We don't allow setting
>>> that bit in the first place.
>>
>> I think it's more consistent to mask it off, specifically with the code
>> visible in context right above the insertion. The doc isn't really clear
>> about readability of that bit: On one hand in says R/W for port 0x70 in
>> the NMI_EN section, yet otoh in the RTC section it says "Note that port
>> 70h is not directly readable. The only way to read this register is
>> through Alt Access mode." (I think the NMI_EN section is more trustworthy,
>> but still.) Plus if we were to ever make use of the NMI disable, we
>> wouldn't want Dom0 see the bit set.
> 
> I guess so, at the end Xen itself doesn't use the bit so far.  Maybe
> at some point we would want to expose the value of the bit to dom0 if
> Xen starts using it (most than anything for informative purposes if
> NMIs are disabled).
> 
> Feel free to fold the diff to the existing patch and keep the RB.

Thanks.

> I guess you will also add something to the commit message about the
> special handling of the NMI enable bit even when the RTC/CMOS is not
> present?

Of course, albeit not more than a sentence, as the code comments provide
the details.

Jan



 


Rackspace

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