All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eduardo Habkost <ehabkost@redhat.com>
To: Vitaly Kuznetsov <vkuznets@redhat.com>
Cc: Igor Mammedov <imammedo@redhat.com>,
	Marcelo Tosatti <mtosatti@redhat.com>,
	qemu-devel@nongnu.org, Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [PATCH 5/5] i386: provide simple 'hyperv=on' option to x86 machine types
Date: Mon, 4 Jan 2021 13:29:06 -0500	[thread overview]
Message-ID: <20210104182906.GD18467@habkost.net> (raw)
In-Reply-To: <87r1n0j20n.fsf@vitty.brq.redhat.com>

On Mon, Jan 04, 2021 at 01:54:32PM +0100, Vitaly Kuznetsov wrote:
> Igor Mammedov <imammedo@redhat.com> writes:
> 
> >> >  
> >> > +    /* Hyper-V features enabled with 'hyperv=on' */
> >> > +    x86mc->default_hyperv_features = BIT(HYPERV_FEAT_RELAXED) |
> >> > +        BIT(HYPERV_FEAT_VAPIC) | BIT(HYPERV_FEAT_TIME) |
> >> > +        BIT(HYPERV_FEAT_CRASH) | BIT(HYPERV_FEAT_RESET) |
> >> > +        BIT(HYPERV_FEAT_VPINDEX) | BIT(HYPERV_FEAT_RUNTIME) |
> >> > +        BIT(HYPERV_FEAT_SYNIC) | BIT(HYPERV_FEAT_STIMER) |
> >> > +        BIT(HYPERV_FEAT_FREQUENCIES) | BIT(HYPERV_FEAT_REENLIGHTENMENT) |
> >> > +        BIT(HYPERV_FEAT_TLBFLUSH) | BIT(HYPERV_FEAT_EVMCS) |
> >> > +        BIT(HYPERV_FEAT_IPI) | BIT(HYPERV_FEAT_STIMER_DIRECT);
> > I'd argue that feature bits do not belong to machine code at all.
> > If we have to involve machine at all then it should be a set property/value pairs
> > that machine will set on CPU object (I'm not convinced that doing it
> > from machine code is good idea though).
> >
> 
> These are 'features' and not feature bits. 'Bits' here are just our
> internal (to QEMU) representation of which features are enable and which
> are not, we could've just used booleans instead. These feature, when
> enabled, will result in some CPUID changes (not 1:1) but I don't see how
> it's different from
>   
> " -machine q35,accel=kvm "
> 
> which also results in CPUID changes.

This is a good point, although having accel affect CPUID bits was
also a source of complexity for query-cpu-model-expansion and
other QMP queries.

> 
> The main reason for putting this to x86 machine type is versioning, as
> we go along we will (hopefully) be implementing more and more Hyper-V
> features but we want to provide 'one knob to rule them all' but do it in
> a way that will allow migration. We already have 'hv_passthrough' for
> CPU.

I agree completely that the set of bits needs to be on
MachineClass.  We just need to agree on the external interface.

> 
> >> >  
> >> > +    if (x86ms->hyperv_enabled) {
> >> > +        feat = x86mc->default_hyperv_features;
> >> > +        /* Enlightened VMCS is only available on Intel/VMX */
> >> > +        if (!cpu_has_vmx(&cpu->env)) {
> >> > +            feat &= ~BIT(HYPERV_FEAT_EVMCS);
> >> > +        }
> >> > +
> >> > +        cpu->hyperv_features |= feat;
> > that will ignore features user explicitly doesn't want,
> > ex:
> >  -machine hyperv=on -cpu foo,hv-foo=off
> >
> 
> Existing 'hv_passthrough' mode can also affect the result. Personally, I
> don't see where 'hv-foo=off' is needed outside of debugging and these
> use-cases can probably be covered by explicitly listing required
> features but I'm not against making this work, shouldn't be hard.

I'm all for not wasting time supporting use cases that are not
necessary in practice.  We just need to document the expected
behavior clearly, whatever we decide to do.

> 
> > not sure we would like to introduce such invariant,
> > in normal qom property handling the latest set property should have effect
> > (all other invariants we have in x86 cpu property semantics are comming from legacy handling
> > and I plan to deprecate them (it will affect x86 and sparc cpus) so CPUs will behave like
> > any other QOM object when it come to property handling)
> >  
> > anyways it's confusing a bit to have cpu flags to come from 2 different places
> >
> > -cpu hyperv-use-preset=on,hv-foo=off
> >
> > looks less confusing and will heave expected effect
> >
> 
> Honestly, 'hyperv-use-preset' is confusing even to me :-)
> 
> What if we for a second stop thinking about Hyper-V features being CPU
> features only, e.g. if we want to create Dynamic Memory or PTP or any
> other Hyper-V specific device in a simple way? We'll have to put these
> under machine type.

I agree.  Hyper-V is not just a set of CPU features.

Also, those two approaches are not mutually exclusive.
"-machine hyperv=on" can be implemented internally using
"hyperv-use-preset=on" if necessary.  I don't think it has to,
however.

-- 
Eduardo



  reply	other threads:[~2021-01-04 18:30 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-19 10:32 [PATCH 0/5] i386: simplify Hyper-V enlightenments enablement Vitaly Kuznetsov
2020-11-19 10:32 ` [PATCH 1/5] i386: move hyperv_vendor_id initialization to x86_cpu_realizefn() Vitaly Kuznetsov
2021-03-10 11:27   ` Claudio Fontana
2021-03-10 11:43     ` Vitaly Kuznetsov
2021-03-10 12:18       ` Claudio Fontana
2021-03-10 13:13         ` Vitaly Kuznetsov
2020-11-19 10:32 ` [PATCH 2/5] i386: move hyperv_interface_id " Vitaly Kuznetsov
2020-11-19 10:32 ` [PATCH 3/5] i386: move hyperv_version_id " Vitaly Kuznetsov
2020-11-19 10:32 ` [PATCH 4/5] i386: move hyperv_limits " Vitaly Kuznetsov
2020-11-19 10:32 ` [PATCH 5/5] i386: provide simple 'hyperv=on' option to x86 machine types Vitaly Kuznetsov
2020-12-16 20:52   ` Eduardo Habkost
2020-12-17  9:34     ` Vitaly Kuznetsov
2020-12-18 17:13     ` Igor Mammedov
2020-12-18 18:07       ` Eduardo Habkost
2020-12-21 13:24         ` Igor Mammedov
2020-12-21 19:47           ` Eduardo Habkost
2020-12-21 20:39             ` David Hildenbrand
2021-01-04 12:54       ` Vitaly Kuznetsov
2021-01-04 18:29         ` Eduardo Habkost [this message]
2021-01-04 23:36           ` Igor Mammedov
2021-01-05 14:34             ` Eduardo Habkost
2021-01-05 15:10               ` Vitaly Kuznetsov
2021-01-05 16:33                 ` Igor Mammedov
2021-01-05 16:31               ` Igor Mammedov
2021-01-05 17:02                 ` Vitaly Kuznetsov
2021-01-05 18:19                 ` Eduardo Habkost
2021-01-04 23:04         ` Igor Mammedov
2021-01-05 11:50           ` Vitaly Kuznetsov
2021-01-05 16:03             ` Igor Mammedov
2021-01-05 16:31               ` Vitaly Kuznetsov
2021-01-06 13:13                 ` Igor Mammedov
2021-01-06 13:38                   ` Vitaly Kuznetsov
2021-01-06 16:45                     ` Igor Mammedov
2021-01-06 17:25                       ` Eduardo Habkost
2021-01-07  9:14                         ` Vitaly Kuznetsov
2021-01-06 17:02                     ` Eduardo Habkost
2020-11-19 14:22 ` [PATCH 0/5] i386: simplify Hyper-V enlightenments enablement Claudio Fontana
2020-11-19 16:58   ` Vitaly Kuznetsov
2020-12-16 19:09 ` Eduardo Habkost

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=20210104182906.GD18467@habkost.net \
    --to=ehabkost@redhat.com \
    --cc=imammedo@redhat.com \
    --cc=mtosatti@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=vkuznets@redhat.com \
    /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.