[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
On Tue, Apr 18, 2023 at 11:24:19AM +0200, Jan Beulich wrote: > ... in order to also intercept Dom0 accesses through the alias ports. > > Also stop intercepting accesses to the CMOS ports if we won't ourselves > use the CMOS RTC, because of there being none. > > Note that rtc_init() deliberately uses 16 as the upper loop bound, > despite probe_cmos_alias() using 8: The higher bound is benign now, but > would save us touching the code (or, worse, missing to touch it) in case > the lower one was doubled. > > Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx> Reviewed-by: Roger Pau Monné <roger.pau@xxxxxxxxxx> > --- > v6: Restore lost "return" in rtc_init(). Convert printk() to dprintk() > in probe_cmos_alias(). Correct is_cmos_port() for hwdom. > v5: Simplify logic in is_cmos_port(). Limit the scope of a local > variable. Adjust a comment that's being moved. > v4: Also conditionally mask top bit for guest index port accesses. Add > missing adjustments to rtc_init(). Re-work to avoid recursive > read_lock(). Also adjust guest_io_{read,write}(). Re-base. > v3: Re-base over change to earlier patch. > v2: Re-base. > > --- a/xen/arch/x86/hvm/rtc.c > +++ b/xen/arch/x86/hvm/rtc.c > @@ -27,7 +27,7 @@ > #include <asm/hvm/vpt.h> > #include <asm/hvm/io.h> > #include <asm/hvm/save.h> > -#include <asm/current.h> > +#include <asm/iocap.h> > #include <xen/trace.h> > #include <public/hvm/params.h> > > @@ -836,9 +836,19 @@ void rtc_init(struct domain *d) > > if ( !has_vrtc(d) ) > { > - if ( is_hardware_domain(d) ) > - /* Hardware domain gets mediated access to the physical RTC. */ > - register_portio_handler(d, RTC_PORT(0), 2, hw_rtc_io); > + unsigned int port; > + > + if ( !is_hardware_domain(d) ) > + return; > + > + /* > + * Hardware domain gets mediated access to the physical RTC/CMOS (of > + * course unless we don't use it ourselves, for there being none). > + */ > + for ( port = RTC_PORT(0); port < RTC_PORT(0) + 0x10; port += 2 ) > + if ( is_cmos_port(port, 2, d) ) > + register_portio_handler(d, port, 2, hw_rtc_io); > + > return; > } > > --- a/xen/arch/x86/include/asm/mc146818rtc.h > +++ b/xen/arch/x86/include/asm/mc146818rtc.h > @@ -9,6 +9,10 @@ > > extern spinlock_t rtc_lock; /* serialize CMOS RAM access */ > > +struct domain; > +bool is_cmos_port(unsigned int port, unsigned int bytes, > + const struct domain *d); > + > /********************************************************************** > * register summary > **********************************************************************/ > --- a/xen/arch/x86/pv/emul-priv-op.c > +++ b/xen/arch/x86/pv/emul-priv-op.c > @@ -208,7 +208,7 @@ static bool admin_io_okay(unsigned int p > return false; > > /* We also never permit direct access to the RTC/CMOS registers. */ Hm, it's unclear to me whether the comment above would need updating: we don't allow direct access to the RTC/CMOS registers, but we allow direct access to the RTC/CMOS ports if there's no device behind. Thanks, Roger.
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |