lkml.org 
[lkml]   [2022]   [Mar]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCHv6 15/30] x86/boot: Port I/O: allow to hook up alternative helpers
On Thu, Mar 17, 2022 at 01:12:59PM +0100, Thomas Gleixner wrote:
> On Wed, Mar 16 2022 at 05:08, Kirill A. Shutemov wrote:
> > +#undef inb
> > +#undef inw
> > +#undef inl
> > +#undef outb
> > +#undef outw
> > +#undef outl
> > +
> > +struct port_io_ops {
> > + u8 (*inb)(u16 port);
> > + u16 (*inw)(u16 port);
> > + u32 (*inl)(u16 port);
> > + void (*outb)(u8 v, u16 port);
> > + void (*outw)(u16 v, u16 port);
> > + void (*outl)(u32 v, u16 port);
>
> u8 (*inb)(u16 port);
> void (*outb)(u8 v, u16 port);
> void (*outw)(u16 v, u16 port);
>
> is all what's used AFAICT.

Hm. Okay. I will drop the rest.

> > +};
> > +
> > +extern struct port_io_ops pio_ops;
> > +
> > +/*
> > + * Use the normal I/O instructions by default.
> > + * TDX guests override these to use hypercalls.
> > + */
> > +static inline void init_default_io_ops(void)
> > +{
> > + pio_ops.inb = __inb;
> > + pio_ops.inw = __inw;
> > + pio_ops.inl = __inl;
> > + pio_ops.outb = __outb;
> > + pio_ops.outw = __outw;
> > + pio_ops.outl = __outl;
> > +}
>
> #define DEFINE_PORT_IO_OPS() \
> struct port_io_ops pio_ops = { \
> .inb = __inb, \
> .outb = __outb, \
> .outw = __outw, }
>
> Hmm?

This kind of initializations are problematic. They generate run-time
relacations that kernel cannot handle in the boot stub. Linker complains
about this:

ld.lld: error: Unexpected run-time relocations (.rela) detected!

I will leave it as is, unless you have better ideas.

--
Kirill A. Shutemov

\
 
 \ /
  Last update: 2022-03-17 21:16    [W:2.076 / U:0.704 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site