All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Beulich <jbeulich@suse.com>
To: Wei Liu <wl@xen.org>
Cc: "Andrew Cooper" <andrew.cooper3@citrix.com>,
	"Michael Kelley" <mikelley@microsoft.com>,
	"Wei Liu" <liuwe@microsoft.com>,
	"Xen Development List" <xen-devel@lists.xenproject.org>,
	"Roger Pau Monné" <roger.pau@citrix.com>
Subject: Re: [Xen-devel] [PATCH for-next v3 9/9] x86: introduce CONFIG_HYPERV and detection code
Date: Thu, 21 Nov 2019 17:59:16 +0100	[thread overview]
Message-ID: <a71f7987-751f-a13e-e73c-653a802ea30b@suse.com> (raw)
In-Reply-To: <20191121162700.hpkrjcuebdylttjm@debian>

On 21.11.2019 17:27, Wei Liu wrote:
> On Fri, Nov 15, 2019 at 03:07:29PM +0100, Jan Beulich wrote:
>> On 21.10.2019 17:57, Wei Liu wrote:
>>> --- a/xen/arch/x86/Kconfig
>>> +++ b/xen/arch/x86/Kconfig
>>> @@ -164,6 +164,15 @@ endchoice
>>>  config GUEST
>>>  	bool
>>>  
>>> +config HYPERV_GUEST
>>> +	def_bool n
>>> +	select GUEST
>>> +	prompt "Hyper-V Guest"
>>
>> Please can you avoid following the bad example XEN_GUEST gives (and
>> perhaps even take the opportunity here or in the earlier patch
>> adding GUEST to change that one as well)? What you want is
>>
>> config HYPERV_GUEST
>> 	bool "Hyper-V Guest"
>> 	select GUEST
> 
> Ack.
> 
>>
>>> --- /dev/null
>>> +++ b/xen/arch/x86/guest/hyperv/hyperv.c
>>> @@ -0,0 +1,54 @@
>>> +/******************************************************************************
>>> + * arch/x86/guest/hyperv/hyperv.c
>>> + *
>>> + * Support for detecting and running under Hyper-V.
>>> + *
>>> + * This program is free software; you can redistribute it and/or modify
>>> + * it under the terms of the GNU General Public License as published by
>>> + * the Free Software Foundation; either version 2 of the License, or
>>> + * (at your option) any later version.
>>> + *
>>> + * This program is distributed in the hope that it will be useful,
>>> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
>>> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
>>> + * GNU General Public License for more details.
>>> + *
>>> + * You should have received a copy of the GNU General Public License
>>> + * along with this program; If not, see <http://www.gnu.org/licenses/>.
>>> + *
>>> + * Copyright (c) 2019 Microsoft.
>>> + */
>>> +#include <xen/init.h>
>>> +
>>> +#include <asm/guest.h>
>>> +
>>> +bool __init hyperv_probe(void)
>>> +{
>>> +    uint32_t eax, ebx, ecx, edx;
>>> +
>>> +    cpuid(0x40000000, &eax, &ebx, &ecx, &edx);
>>> +    if ( !((ebx == 0x7263694d) &&  /* "Micr" */
>>> +           (ecx == 0x666f736f) &&  /* "osof" */
>>> +           (edx == 0x76482074)) )  /* "t Hv" */
>>> +        return false;
>>> +
>>> +    cpuid(0x40000001, &eax, &ebx, &ecx, &edx);
>>> +    if ( eax != 0x31237648 )    /* Hv#1 */
>>> +        return false;
>>> +
>>> +    return true;
>>> +}
>>> +
>>> +struct hypervisor_ops hyperv_ops = {
>>
>> const again.
>>
>>> --- a/xen/arch/x86/guest/hypervisor.c
>>> +++ b/xen/arch/x86/guest/hypervisor.c
>>> @@ -43,6 +43,14 @@ bool hypervisor_probe(void)
>>>      }
>>>  #endif
>>>  
>>> +#ifdef CONFIG_HYPERV_GUEST
>>> +    if ( hyperv_probe() )
>>> +    {
>>> +        hops = &hyperv_ops;
>>> +        return true;
>>> +    }
>>> +#endif
>>
>> This recurring #ifdef CONFIG_*_GUEST is going to start looking ugly
>> the latest when one or two more get added. Perhaps better providing
>> *_probe() stubs returning false, and (like we do elsewhere) rely on
>> DCE to get rid of the *_ops reference? (And really you already have
>> such a stub - all you need to do is put the hyperv_ops declaration
>> outside the #ifdef (but read on).
>>
>> Also how about having *_probe() return the address of *_ops, such
>> that the latter could all become static?
> 
> Previously you made a suggestion to make probe return the name of the
> hypervisor. Here you ask for address of ops. I actually prefer the
> method suggested here, but this means I will need to keep
> hypervisor_name around.

Is there actually any user of the name field other than the caller
of probe? If not, surely that caller could access the name field
without a hypervisor_name() wrapper.

Jan

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  reply	other threads:[~2019-11-21 16:59 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-21 15:57 [Xen-devel] [PATCH for-next v3 0/9] Port Xen to Hyper-V Wei Liu
2019-10-21 15:57 ` [Xen-devel] [PATCH for-next v3 1/9] x86: introduce CONFIG_GUEST and move code Wei Liu
2019-10-23  7:55   ` Paul Durrant
2019-10-23 10:49     ` Wei Liu
2019-11-15 13:34   ` Jan Beulich
2019-10-21 15:57 ` [Xen-devel] [PATCH for-next v3 2/9] x86: include asm_defns.h directly in hypercall.h Wei Liu
2019-11-15 13:36   ` Jan Beulich
2019-10-21 15:57 ` [Xen-devel] [PATCH for-next v3 3/9] x86: drop hypervisor_cpuid_base Wei Liu
2019-11-15 13:39   ` Jan Beulich
2019-10-21 15:57 ` [Xen-devel] [PATCH for-next v3 4/9] x86: include xen/lib.h in guest/hypercall.h Wei Liu
2019-11-15 13:40   ` Jan Beulich
2019-10-21 15:57 ` [Xen-devel] [PATCH for-next v3 5/9] x86: introduce hypervisor framework Wei Liu
2019-10-23  8:19   ` Paul Durrant
2019-11-15 13:48   ` Jan Beulich
2019-11-21 16:27     ` Wei Liu
2019-10-21 15:57 ` [Xen-devel] [PATCH for-next v3 6/9] x86: rename hypervisor_{alloc, free}_unused_page Wei Liu
2019-11-15 13:49   ` Jan Beulich
2019-11-21 16:27     ` Wei Liu
2019-10-21 15:57 ` [Xen-devel] [PATCH for-next v3 7/9] x86: switch xen implementation to use hypervisor framework Wei Liu
2019-10-23  9:02   ` Paul Durrant
2019-11-15 13:56   ` Jan Beulich
2019-10-21 15:57 ` [Xen-devel] [PATCH for-next v3 8/9] x86: be more verbose when running on a hypervisor Wei Liu
2019-10-23  9:03   ` Paul Durrant
2019-11-15 13:59   ` Jan Beulich
2019-10-21 15:57 ` [Xen-devel] [PATCH for-next v3 9/9] x86: introduce CONFIG_HYPERV and detection code Wei Liu
2019-10-23  9:07   ` Paul Durrant
2019-10-23 10:50     ` Wei Liu
2019-11-15 14:07   ` Jan Beulich
2019-11-21 16:27     ` Wei Liu
2019-11-21 16:59       ` Jan Beulich [this message]
2019-11-21 17:02         ` Wei Liu

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=a71f7987-751f-a13e-e73c-653a802ea30b@suse.com \
    --to=jbeulich@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=liuwe@microsoft.com \
    --cc=mikelley@microsoft.com \
    --cc=roger.pau@citrix.com \
    --cc=wl@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.