All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Jan Beulich <JBeulich@suse.com>,
	xen-devel <xen-devel@lists.xenproject.org>
Cc: Keir Fraser <keir@xen.org>
Subject: Re: [PATCH] x86: detect CMOS aliasing on ports other then 0x70/0x71
Date: Wed, 23 Sep 2015 19:34:38 +0100	[thread overview]
Message-ID: <5602F0BE.6070801@citrix.com> (raw)
In-Reply-To: <56016F7B02000078000A45DA@prv-mh.provo.novell.com>

On 22/09/15 14:10, Jan Beulich wrote:
> +    for ( offs = 2; offs < 8; offs <<= 1 )
> +    {
> +        bool_t read = 1;
> +
> +        for ( i = RTC_REG_D + 1; i < 0x80; ++i )
> +        {
> +            uint8_t normal, alt;
> +            unsigned long flags;
> +
> +            if ( i == acpi_gbl_FADT.century )
> +                continue;
> +
> +            spin_lock_irqsave(&rtc_lock, flags);
> +
> +            normal = CMOS_READ(i);
> +            if ( inb(RTC_PORT(offs)) != i )
> +                read = 0;
> +
> +            alt = inb(RTC_PORT(offs + 1));
> +
> +            spin_unlock_irqrestore(&rtc_lock, flags);
> +
> +            if ( normal != alt )
> +                break;

Even with a manual to hand, this logic is quite hard to understand. 
Furthermore, I still cant spot how your r/w vs w/o logic is supposed to
work.  It doesn't check the writability of the alias, but of the aliases
index.

However, it is not robust to the system servicing an SMI and altering
the CMOS ram in the middle of this loop.  Such a modification would
cause the loop to believe that this specific 'offs' is not an alias even
when it actually is.

One option would be to reread the non-aliased port again, but that would
add yet more io reads.

~Andrew

  reply	other threads:[~2015-09-23 18:34 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-22 13:10 [PATCH] x86: detect CMOS aliasing on ports other then 0x70/0x71 Jan Beulich
2015-09-23 18:34 ` Andrew Cooper [this message]
2015-09-24  8:11   ` Jan Beulich
2015-09-25  9:55     ` Andrew Cooper
2015-09-25 11:00       ` Jan Beulich
2015-09-29 13:25         ` Andrew Cooper
2015-09-29 13:42           ` Jan Beulich

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=5602F0BE.6070801@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=JBeulich@suse.com \
    --cc=keir@xen.org \
    --cc=xen-devel@lists.xenproject.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.