Re: [PATCH v2 1/2] xen/domain: introduce non-x86 hardware emulation flags

2025-05-28 Thread dmkhn
On Wed, May 21, 2025 at 04:05:04PM +0200, Roger Pau Monné wrote:
> On Fri, May 16, 2025 at 02:29:09AM +, dm...@proton.me wrote:
> > From: Denis Mukhin 
> >
> > Define per-architecture emulation_flags for configuring domain emulation
> > features.
> >
> > Print d->arch.emulation_flags from 'q' keyhandler for better traceability
> > while debugging.
> >
> > Signed-off-by: Denis Mukhin 
> > ---
> > Changes since v1:
> > - dropped comments
> > ---
> >  xen/arch/arm/include/asm/domain.h   | 1 +
> >  xen/arch/ppc/include/asm/domain.h   | 1 +
> >  xen/arch/riscv/include/asm/domain.h | 1 +
> >  xen/common/keyhandler.c | 1 +
> >  4 files changed, 4 insertions(+)
> >
> > diff --git a/xen/arch/arm/include/asm/domain.h 
> > b/xen/arch/arm/include/asm/domain.h
> > index a3487ca713..70e6e7d49b 100644
> > --- a/xen/arch/arm/include/asm/domain.h
> > +++ b/xen/arch/arm/include/asm/domain.h
> > @@ -121,6 +121,7 @@ struct arch_domain
> >  void *tee;
> >  #endif
> >
> > +uint32_t emulation_flags;
> >  }  __cacheline_aligned;
> >
> >  struct arch_vcpu
> > diff --git a/xen/arch/ppc/include/asm/domain.h 
> > b/xen/arch/ppc/include/asm/domain.h
> > index 3a447272c6..001116a0ab 100644
> > --- a/xen/arch/ppc/include/asm/domain.h
> > +++ b/xen/arch/ppc/include/asm/domain.h
> > @@ -21,6 +21,7 @@ struct arch_vcpu {
> >
> >  struct arch_domain {
> >  struct hvm_domain hvm;
> > +uint32_t emulation_flags;
> >  };
> >
> >  #include 
> > diff --git a/xen/arch/riscv/include/asm/domain.h 
> > b/xen/arch/riscv/include/asm/domain.h
> > index c3d965a559..7bc242da55 100644
> > --- a/xen/arch/riscv/include/asm/domain.h
> > +++ b/xen/arch/riscv/include/asm/domain.h
> > @@ -18,6 +18,7 @@ struct arch_vcpu {
> >
> >  struct arch_domain {
> >  struct hvm_domain hvm;
> > +uint32_t emulation_flags;
> >  };
> >
> >  #include 
> > diff --git a/xen/common/keyhandler.c b/xen/common/keyhandler.c
> > index 0bb842ec00..73f5134b68 100644
> > --- a/xen/common/keyhandler.c
> > +++ b/xen/common/keyhandler.c
> > @@ -306,6 +306,7 @@ static void cf_check dump_domains(unsigned char key)
> >  if ( test_bit(i, &d->watchdog_inuse_map) )
> >  printk("watchdog %d expires in %d seconds\n",
> > i, (u32)((d->watchdog_timer[i].expires - NOW()) >> 
> > 30));
> > +printk("emulation_flags %#x\n", d->arch.emulation_flags);
> >
> >  arch_dump_domain_info(d);
> 
> Hello,
> 
> I think it might be easier to print emulation_flags in
> arch_dump_domain_info(), ideally it would be helpful if this could be
> printed in a user friendly way apart from the raw dump:
> 
> printk("emulation_flags:%s%s... (%#x)\n",
>!d->arch.emulation_flags ? " none" : "",
>has_vlapic(d) ? " lapic" : "", ...
>d->arch.emulation_flags);

I moved emulation_flags to the common domain struct in v3 and I kept the
emulation_flags flags printout here in common dump_domains().

I will plumb the human-readable printout for x86 flags in the follow on patch.

> 
> Regards, Roger.




Re: [PATCH v2 1/2] xen/domain: introduce non-x86 hardware emulation flags

2025-05-21 Thread Roger Pau Monné
On Fri, May 16, 2025 at 02:29:09AM +, dm...@proton.me wrote:
> From: Denis Mukhin 
> 
> Define per-architecture emulation_flags for configuring domain emulation
> features.
> 
> Print d->arch.emulation_flags from 'q' keyhandler for better traceability
> while debugging.
> 
> Signed-off-by: Denis Mukhin 
> ---
> Changes since v1:
> - dropped comments
> ---
>  xen/arch/arm/include/asm/domain.h   | 1 +
>  xen/arch/ppc/include/asm/domain.h   | 1 +
>  xen/arch/riscv/include/asm/domain.h | 1 +
>  xen/common/keyhandler.c | 1 +
>  4 files changed, 4 insertions(+)
> 
> diff --git a/xen/arch/arm/include/asm/domain.h 
> b/xen/arch/arm/include/asm/domain.h
> index a3487ca713..70e6e7d49b 100644
> --- a/xen/arch/arm/include/asm/domain.h
> +++ b/xen/arch/arm/include/asm/domain.h
> @@ -121,6 +121,7 @@ struct arch_domain
>  void *tee;
>  #endif
>  
> +uint32_t emulation_flags;
>  }  __cacheline_aligned;
>  
>  struct arch_vcpu
> diff --git a/xen/arch/ppc/include/asm/domain.h 
> b/xen/arch/ppc/include/asm/domain.h
> index 3a447272c6..001116a0ab 100644
> --- a/xen/arch/ppc/include/asm/domain.h
> +++ b/xen/arch/ppc/include/asm/domain.h
> @@ -21,6 +21,7 @@ struct arch_vcpu {
>  
>  struct arch_domain {
>  struct hvm_domain hvm;
> +uint32_t emulation_flags;
>  };
>  
>  #include 
> diff --git a/xen/arch/riscv/include/asm/domain.h 
> b/xen/arch/riscv/include/asm/domain.h
> index c3d965a559..7bc242da55 100644
> --- a/xen/arch/riscv/include/asm/domain.h
> +++ b/xen/arch/riscv/include/asm/domain.h
> @@ -18,6 +18,7 @@ struct arch_vcpu {
>  
>  struct arch_domain {
>  struct hvm_domain hvm;
> +uint32_t emulation_flags;
>  };
>  
>  #include 
> diff --git a/xen/common/keyhandler.c b/xen/common/keyhandler.c
> index 0bb842ec00..73f5134b68 100644
> --- a/xen/common/keyhandler.c
> +++ b/xen/common/keyhandler.c
> @@ -306,6 +306,7 @@ static void cf_check dump_domains(unsigned char key)
>  if ( test_bit(i, &d->watchdog_inuse_map) )
>  printk("watchdog %d expires in %d seconds\n",
> i, (u32)((d->watchdog_timer[i].expires - NOW()) >> 
> 30));
> +printk("emulation_flags %#x\n", d->arch.emulation_flags);
>  
>  arch_dump_domain_info(d);

Hello,

I think it might be easier to print emulation_flags in
arch_dump_domain_info(), ideally it would be helpful if this could be
printed in a user friendly way apart from the raw dump:

printk("emulation_flags:%s%s... (%#x)\n",
   !d->arch.emulation_flags ? " none" : "",
   has_vlapic(d) ? " lapic" : "", ...
   d->arch.emulation_flags);

Regards, Roger.



Re: [PATCH v2 1/2] xen/domain: introduce non-x86 hardware emulation flags

2025-05-20 Thread Jan Beulich
On 20.05.2025 23:39, dm...@proton.me wrote:
> On Tue, May 20, 2025 at 05:21:06PM +0200, Jan Beulich wrote:
>> On 16.05.2025 04:29, dm...@proton.me wrote:
>>> From: Denis Mukhin 
>>>
>>> Define per-architecture emulation_flags for configuring domain emulation
>>> features.
>>>
>>> Print d->arch.emulation_flags from 'q' keyhandler for better traceability
>>> while debugging.
>>>
>>> Signed-off-by: Denis Mukhin 
>>> ---
>>> Changes since v1:
>>> - dropped comments
>>> ---
>>>  xen/arch/arm/include/asm/domain.h   | 1 +
>>>  xen/arch/ppc/include/asm/domain.h   | 1 +
>>>  xen/arch/riscv/include/asm/domain.h | 1 +
>>>  xen/common/keyhandler.c | 1 +
>>>  4 files changed, 4 insertions(+)
>>
>> If every arch gains identical fields, accessed from common code, why would
>> those need to live in struct arch_domain?
> 
> I did it this way to keep the diff smaller, but I agree such property
> makes sense to put in common domain struct. Will update in v3.

Provided there's arch maintainer buy-off on generalizing this. There's (at
least) a 3rd option, after all: Have arch-specific and (separate) common
emulation flags.

Jan



Re: [PATCH v2 1/2] xen/domain: introduce non-x86 hardware emulation flags

2025-05-20 Thread dmkhn
On Tue, May 20, 2025 at 05:21:06PM +0200, Jan Beulich wrote:
> On 16.05.2025 04:29, dm...@proton.me wrote:
> > From: Denis Mukhin 
> >
> > Define per-architecture emulation_flags for configuring domain emulation
> > features.
> >
> > Print d->arch.emulation_flags from 'q' keyhandler for better traceability
> > while debugging.
> >
> > Signed-off-by: Denis Mukhin 
> > ---
> > Changes since v1:
> > - dropped comments
> > ---
> >  xen/arch/arm/include/asm/domain.h   | 1 +
> >  xen/arch/ppc/include/asm/domain.h   | 1 +
> >  xen/arch/riscv/include/asm/domain.h | 1 +
> >  xen/common/keyhandler.c | 1 +
> >  4 files changed, 4 insertions(+)
> 
> If every arch gains identical fields, accessed from common code, why would
> those need to live in struct arch_domain?

I did it this way to keep the diff smaller, but I agree such property
makes sense to put in common domain struct. Will update in v3.

Thanks!

> 
> Jan




Re: [PATCH v2 1/2] xen/domain: introduce non-x86 hardware emulation flags

2025-05-20 Thread Jan Beulich
On 16.05.2025 04:29, dm...@proton.me wrote:
> From: Denis Mukhin 
> 
> Define per-architecture emulation_flags for configuring domain emulation
> features.
> 
> Print d->arch.emulation_flags from 'q' keyhandler for better traceability
> while debugging.
> 
> Signed-off-by: Denis Mukhin 
> ---
> Changes since v1:
> - dropped comments
> ---
>  xen/arch/arm/include/asm/domain.h   | 1 +
>  xen/arch/ppc/include/asm/domain.h   | 1 +
>  xen/arch/riscv/include/asm/domain.h | 1 +
>  xen/common/keyhandler.c | 1 +
>  4 files changed, 4 insertions(+)

If every arch gains identical fields, accessed from common code, why would
those need to live in struct arch_domain?

Jan