Signed-off-by: Wei Liu <liuwe@microsoft.com>
---
xen/arch/x86/guest/hypervisor.c | 5 +++++
xen/arch/x86/setup.c | 6 +++++-
xen/include/asm-x86/guest/hypervisor.h | 2 ++
3 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/xen/arch/x86/guest/hypervisor.c b/xen/arch/x86/guest/hypervisor.c
index 30453b6a7a..8161b26c5a 100644
--- a/xen/arch/x86/guest/hypervisor.c
+++ b/xen/arch/x86/guest/hypervisor.c
@@ -43,6 +43,11 @@ bool hypervisor_probe(void)
return !!hops;
}
+const char *hypervisor_name(void)
+{
+ return hops->name;
+}
+
void hypervisor_setup(void)
{
if ( hops && hops->setup )
diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c
index 0ee11b15a6..cf5a7b8e1e 100644
--- a/xen/arch/x86/setup.c
+++ b/xen/arch/x86/setup.c
@@ -689,6 +689,7 @@ void __init noreturn __start_xen(unsigned long mbi_p)
int i, j, e820_warn = 0, bytes = 0;
bool acpi_boot_table_init_done = false, relocated = false;
int ret;
+ bool running_on_hypervisor;
struct ns16550_defaults ns16550 = {
.data_bits = 8,
.parity = 'n',
@@ -763,7 +764,7 @@ void __init noreturn __start_xen(unsigned long mbi_p)
* allocing any xenheap structures wanted in lower memory. */
kexec_early_calculations();
- hypervisor_probe();
+ running_on_hypervisor = hypervisor_probe();
parse_video_info();
@@ -789,6 +790,9 @@ void __init noreturn __start_xen(unsigned long mbi_p)
printk("Xen image load base address: %#lx\n", xen_phys_start);
+ if ( running_on_hypervisor )
+ printk("Running on %s\n", hypervisor_name());
+
#ifdef CONFIG_VIDEO
printk("Video information:\n");
diff --git a/xen/include/asm-x86/guest/hypervisor.h b/xen/include/asm-x86/guest/hypervisor.h
index 38344e2e89..a7d75bf9cf 100644
--- a/xen/include/asm-x86/guest/hypervisor.h
+++ b/xen/include/asm-x86/guest/hypervisor.h
@@ -36,6 +36,7 @@ bool hypervisor_probe(void);
void hypervisor_setup(void);
void hypervisor_ap_setup(void);
void hypervisor_resume(void);
+const char *hypervisor_name(void);
#else
@@ -45,6 +46,7 @@ static inline bool hypervisor_probe(void) { return false; }
static inline void hypervisor_setup(void) {}
static inline void hypervisor_ap_setup(void) {}
static inline void hypervisor_resume(void) {}
+static inline char *hypervisor_name(void) { return NULL; }
#endif /* CONFIG_GUEST */
--
2.20.1
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
On Mon, Sep 30, 2019 at 04:00:42PM +0100, Wei Liu wrote:
> Signed-off-by: Wei Liu <liuwe@microsoft.com>
> ---
> xen/arch/x86/guest/hypervisor.c | 5 +++++
> xen/arch/x86/setup.c | 6 +++++-
> xen/include/asm-x86/guest/hypervisor.h | 2 ++
> 3 files changed, 12 insertions(+), 1 deletion(-)
>
> diff --git a/xen/arch/x86/guest/hypervisor.c b/xen/arch/x86/guest/hypervisor.c
> index 30453b6a7a..8161b26c5a 100644
> --- a/xen/arch/x86/guest/hypervisor.c
> +++ b/xen/arch/x86/guest/hypervisor.c
> @@ -43,6 +43,11 @@ bool hypervisor_probe(void)
> return !!hops;
> }
>
> +const char *hypervisor_name(void)
> +{
I would maybe add ASSERT(hops);
> + return hops->name;
> +}
> +
> void hypervisor_setup(void)
> {
> if ( hops && hops->setup )
> diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c
> index 0ee11b15a6..cf5a7b8e1e 100644
> --- a/xen/arch/x86/setup.c
> +++ b/xen/arch/x86/setup.c
> @@ -689,6 +689,7 @@ void __init noreturn __start_xen(unsigned long mbi_p)
> int i, j, e820_warn = 0, bytes = 0;
> bool acpi_boot_table_init_done = false, relocated = false;
> int ret;
> + bool running_on_hypervisor;
> struct ns16550_defaults ns16550 = {
> .data_bits = 8,
> .parity = 'n',
> @@ -763,7 +764,7 @@ void __init noreturn __start_xen(unsigned long mbi_p)
> * allocing any xenheap structures wanted in lower memory. */
> kexec_early_calculations();
>
> - hypervisor_probe();
> + running_on_hypervisor = hypervisor_probe();
>
> parse_video_info();
>
> @@ -789,6 +790,9 @@ void __init noreturn __start_xen(unsigned long mbi_p)
>
> printk("Xen image load base address: %#lx\n", xen_phys_start);
>
> + if ( running_on_hypervisor )
> + printk("Running on %s\n", hypervisor_name());
> +
> #ifdef CONFIG_VIDEO
> printk("Video information:\n");
>
> diff --git a/xen/include/asm-x86/guest/hypervisor.h b/xen/include/asm-x86/guest/hypervisor.h
> index 38344e2e89..a7d75bf9cf 100644
> --- a/xen/include/asm-x86/guest/hypervisor.h
> +++ b/xen/include/asm-x86/guest/hypervisor.h
> @@ -36,6 +36,7 @@ bool hypervisor_probe(void);
> void hypervisor_setup(void);
> void hypervisor_ap_setup(void);
> void hypervisor_resume(void);
> +const char *hypervisor_name(void);
>
> #else
>
> @@ -45,6 +46,7 @@ static inline bool hypervisor_probe(void) { return false; }
> static inline void hypervisor_setup(void) {}
> static inline void hypervisor_ap_setup(void) {}
> static inline void hypervisor_resume(void) {}
> +static inline char *hypervisor_name(void) { return NULL; }
I think you want an ASSERT_UNREACHABLE here, since hypervisor_name
shouldn't be called unless Xen has detected that's running as a guest,
which can only happen if CONFIG_GUEST is selected.
Thanks, Roger.
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
On Mon, Oct 21, 2019 at 12:00:38PM +0200, Roger Pau Monné wrote:
> On Mon, Sep 30, 2019 at 04:00:42PM +0100, Wei Liu wrote:
> > Signed-off-by: Wei Liu <liuwe@microsoft.com>
> > ---
> > xen/arch/x86/guest/hypervisor.c | 5 +++++
> > xen/arch/x86/setup.c | 6 +++++-
> > xen/include/asm-x86/guest/hypervisor.h | 2 ++
> > 3 files changed, 12 insertions(+), 1 deletion(-)
> >
> > diff --git a/xen/arch/x86/guest/hypervisor.c b/xen/arch/x86/guest/hypervisor.c
> > index 30453b6a7a..8161b26c5a 100644
> > --- a/xen/arch/x86/guest/hypervisor.c
> > +++ b/xen/arch/x86/guest/hypervisor.c
> > @@ -43,6 +43,11 @@ bool hypervisor_probe(void)
> > return !!hops;
> > }
> >
> > +const char *hypervisor_name(void)
> > +{
>
> I would maybe add ASSERT(hops);
>
> > + return hops->name;
> > +}
> > +
[...]
> > diff --git a/xen/include/asm-x86/guest/hypervisor.h b/xen/include/asm-x86/guest/hypervisor.h
> > index 38344e2e89..a7d75bf9cf 100644
> > --- a/xen/include/asm-x86/guest/hypervisor.h
> > +++ b/xen/include/asm-x86/guest/hypervisor.h
> > @@ -36,6 +36,7 @@ bool hypervisor_probe(void);
> > void hypervisor_setup(void);
> > void hypervisor_ap_setup(void);
> > void hypervisor_resume(void);
> > +const char *hypervisor_name(void);
> >
> > #else
> >
> > @@ -45,6 +46,7 @@ static inline bool hypervisor_probe(void) { return false; }
> > static inline void hypervisor_setup(void) {}
> > static inline void hypervisor_ap_setup(void) {}
> > static inline void hypervisor_resume(void) {}
> > +static inline char *hypervisor_name(void) { return NULL; }
>
> I think you want an ASSERT_UNREACHABLE here, since hypervisor_name
> shouldn't be called unless Xen has detected that's running as a guest,
> which can only happen if CONFIG_GUEST is selected.
Ack to both comments.
Wei.
>
> Thanks, Roger.
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
On 21.10.2019 12:00, Roger Pau Monné wrote:
> On Mon, Sep 30, 2019 at 04:00:42PM +0100, Wei Liu wrote:
>> --- a/xen/include/asm-x86/guest/hypervisor.h
>> +++ b/xen/include/asm-x86/guest/hypervisor.h
>> @@ -36,6 +36,7 @@ bool hypervisor_probe(void);
>> void hypervisor_setup(void);
>> void hypervisor_ap_setup(void);
>> void hypervisor_resume(void);
>> +const char *hypervisor_name(void);
>>
>> #else
>>
>> @@ -45,6 +46,7 @@ static inline bool hypervisor_probe(void) { return false; }
>> static inline void hypervisor_setup(void) {}
>> static inline void hypervisor_ap_setup(void) {}
>> static inline void hypervisor_resume(void) {}
>> +static inline char *hypervisor_name(void) { return NULL; }
>
> I think you want an ASSERT_UNREACHABLE here, since hypervisor_name
> shouldn't be called unless Xen has detected that's running as a guest,
> which can only happen if CONFIG_GUEST is selected.
And please bring prototype and stub in sync return-type-wise.
Jan
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
On Wed, Oct 23, 2019 at 03:22:24PM +0200, Jan Beulich wrote:
> On 21.10.2019 12:00, Roger Pau Monné wrote:
> > On Mon, Sep 30, 2019 at 04:00:42PM +0100, Wei Liu wrote:
> >> --- a/xen/include/asm-x86/guest/hypervisor.h
> >> +++ b/xen/include/asm-x86/guest/hypervisor.h
> >> @@ -36,6 +36,7 @@ bool hypervisor_probe(void);
> >> void hypervisor_setup(void);
> >> void hypervisor_ap_setup(void);
> >> void hypervisor_resume(void);
> >> +const char *hypervisor_name(void);
> >>
> >> #else
> >>
> >> @@ -45,6 +46,7 @@ static inline bool hypervisor_probe(void) { return false; }
> >> static inline void hypervisor_setup(void) {}
> >> static inline void hypervisor_ap_setup(void) {}
> >> static inline void hypervisor_resume(void) {}
> >> +static inline char *hypervisor_name(void) { return NULL; }
> >
> > I think you want an ASSERT_UNREACHABLE here, since hypervisor_name
> > shouldn't be called unless Xen has detected that's running as a guest,
> > which can only happen if CONFIG_GUEST is selected.
>
> And please bring prototype and stub in sync return-type-wise.
Missed this comment.
I will handle this if I haven't already.
Wei.
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
© 2016 - 2025 Red Hat, Inc.