From nobody Mon Feb 9 01:16:18 2026 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1571673527; cv=none; d=zoho.com; s=zohoarc; b=GiDEO2jpzfc1i018csCdFG7Mw8/6L4qwrHQ8TI6l6gN9twdtDJQXPwlHOT+BouX9VjgwE9+/OE5I9HAAFWKyEW3nyiiSmmvM/QwSGrjyqdGJFEXqf5sa7ezL7rhDtg7CZp6uauAiSNRkDSruvL8Fp4zgAkApzw7INl6WUg0AePU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571673527; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=QPUV9uldfIQLGALa8fgk+yAQrIIPfQF0ySat2eeBVaA=; b=SG0Di1dShCtEB5ov9cf0hjmI0Ii6JRR2vLN80IiLnWIh/JUq4vthweADO4ImsfIzacJ6sI2y/qgBKLDxdKaFaGyGpEsth9DrJV65nmHgYiduvgBLS5ehaqeo+XXsv5Sab8aj+2jtbUKalwEL1kvM5fAPWPpsQR7YAnIsGbQh4l8= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1571673527693386.3521339879218; Mon, 21 Oct 2019 08:58:47 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iMa46-0008GB-71; Mon, 21 Oct 2019 15:57:50 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iMa44-0008Fq-Sv for xen-devel@lists.xenproject.org; Mon, 21 Oct 2019 15:57:48 +0000 Received: from mail-wm1-x341.google.com (unknown [2a00:1450:4864:20::341]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 7a616f1e-f41b-11e9-bbab-bc764e2007e4; Mon, 21 Oct 2019 15:57:27 +0000 (UTC) Received: by mail-wm1-x341.google.com with SMTP id c22so4239747wmd.1 for ; Mon, 21 Oct 2019 08:57:27 -0700 (PDT) Received: from debian.mshome.net (54.163.200.146.dyn.plus.net. [146.200.163.54]) by smtp.gmail.com with ESMTPSA id x12sm5667410wru.93.2019.10.21.08.57.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Oct 2019 08:57:25 -0700 (PDT) X-Inumbo-ID: 7a616f1e-f41b-11e9-bbab-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=jBrEUmLmtAmRmL0ZQe75O+VGK/lIBJ2eQ4PSZ4jPdH0=; b=EWw8ev4XbD5uXEbn9iAQyd79L3Ub3XQoA5XpmnAjHIi+p9yTY1qcYqgdbn4GuCwPKM Rlj59AsjeQkjg00V1xO4ftnx3kHRwVK7VzxVt2Z8n3RwgEwTa8Nwhw61i6Zr3N9wY8Te pZRJb5uvfKGtLhHMiEKM5RZd+dUZXSo6s3fuecIGR4zH3YDy7SP6QqHTs2cHDYfxN7dY S1fSMXGeHmmBBmDjE91bIX+R99nbh8xkDdmp2bkb3WPqw0SVNhDsQjvsCHEh0dHMduJ7 H0TrKGkcdRJ4yv+mYOzN3YN2nG234Y0RSM09557Xnkg7VZrZJULvTmLetIWIxAor1pjv aGNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=jBrEUmLmtAmRmL0ZQe75O+VGK/lIBJ2eQ4PSZ4jPdH0=; b=M3IWEdkZQysJcPBKWUOKSgAvMUnJ68NyYIKLdfm2ap0D6poYWD0jHKzfZZgMg16Dx5 fM6nPFyKrGRd8QXZRZkigGGR+dTm3LzhI/MFTqnYb4T2FN4I6DuaFp9OXwo725zbXBuo eTCm5AaoVlZaoTcHbCGkJTPYBHkuQ5HJ172WZ+KDkWRWCJqiuZlQAUS4MtEpTU/0cG3e /NYF6Sx4PVSJQLI6WuKn2d8SOkYSgrX8JRmfccQVGp/AT1GUt/yqtynMALmYTpmjUfQq HD+z8J5SBU29WCkFwo7w2gNp3D6KVvy+QbB+Kt3kX0RWXXBal0LtcSUFtcrrLZUWusEa EWIA== X-Gm-Message-State: APjAAAWsUdrXRXqYLNIBgoST8qCD6RpyMBGEFzQvimWb+FggVRbiuunu fLgbJaAAqY5WHbjTMq9XBPGESGedAgI= X-Google-Smtp-Source: APXvYqyO/sJRzgkxKMuVKoWxsxZIEOo3Odlp+bUvQrXRafR6MoUmi6fT+irY1y0FjDTvsdfQs7drpw== X-Received: by 2002:a1c:38c3:: with SMTP id f186mr4252455wma.58.1571673445980; Mon, 21 Oct 2019 08:57:25 -0700 (PDT) From: Wei Liu X-Google-Original-From: Wei Liu To: Xen Development List Date: Mon, 21 Oct 2019 16:57:14 +0100 Message-Id: <20191021155718.28653-6-liuwe@microsoft.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191021155718.28653-1-liuwe@microsoft.com> References: <20191021155718.28653-1-liuwe@microsoft.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH for-next v3 5/9] x86: introduce hypervisor framework X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Wei Liu , Wei Liu , Andrew Cooper , Michael Kelley , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) We will soon implement Hyper-V support for Xen. Add a framework for that. This requires moving some of the hypervisor_* functions from xen.h to hypervisor.h. Signed-off-by: Wei Liu Reviewed-by: Paul Durrant --- xen/arch/x86/guest/Makefile | 2 + xen/arch/x86/guest/hypervisor.c | 45 +++++++++++++++++++ xen/include/asm-x86/guest.h | 1 + xen/include/asm-x86/guest/hypervisor.h | 61 ++++++++++++++++++++++++++ xen/include/asm-x86/guest/xen.h | 12 ----- 5 files changed, 109 insertions(+), 12 deletions(-) create mode 100644 xen/arch/x86/guest/hypervisor.c create mode 100644 xen/include/asm-x86/guest/hypervisor.h diff --git a/xen/arch/x86/guest/Makefile b/xen/arch/x86/guest/Makefile index 6806f04947..f63d64bbee 100644 --- a/xen/arch/x86/guest/Makefile +++ b/xen/arch/x86/guest/Makefile @@ -1 +1,3 @@ +obj-y +=3D hypervisor.o + subdir-$(CONFIG_XEN_GUEST) +=3D xen diff --git a/xen/arch/x86/guest/hypervisor.c b/xen/arch/x86/guest/hyperviso= r.c new file mode 100644 index 0000000000..89b9ae4de0 --- /dev/null +++ b/xen/arch/x86/guest/hypervisor.c @@ -0,0 +1,45 @@ +/*************************************************************************= ***** + * arch/x86/guest/hypervisor.c + * + * Support for detecting and running under a hypervisor. + * + * 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 . + * + * Copyright (c) 2019 Microsoft. + */ + +#include + +#include +#include + +static struct hypervisor_ops *hops __read_mostly; + +bool hypervisor_probe(void) +{ + if ( hops ) + return true; + + return false; +} + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/xen/include/asm-x86/guest.h b/xen/include/asm-x86/guest.h index a38c6b5b3f..8e167165ae 100644 --- a/xen/include/asm-x86/guest.h +++ b/xen/include/asm-x86/guest.h @@ -20,6 +20,7 @@ #define __X86_GUEST_H__ =20 #include +#include #include #include #include diff --git a/xen/include/asm-x86/guest/hypervisor.h b/xen/include/asm-x86/g= uest/hypervisor.h new file mode 100644 index 0000000000..38344e2e89 --- /dev/null +++ b/xen/include/asm-x86/guest/hypervisor.h @@ -0,0 +1,61 @@ +/*************************************************************************= ***** + * asm-x86/guest/hypervisor.h + * + * This program is free software; you can redistribute it and/or + * modify it under the terms and conditions of the GNU General Public + * License, version 2, as published by the Free Software Foundation. + * + * 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 . + * + * Copyright (c) 2019 Microsoft. + */ + +#ifndef __X86_HYPERVISOR_H__ +#define __X86_HYPERVISOR_H__ + +#ifdef CONFIG_GUEST + +struct hypervisor_ops { + /* Name of the hypervisor */ + const char *name; + /* Main setup routine */ + void (*setup)(void); + /* AP setup */ + void (*ap_setup)(void); + /* Resume from suspension */ + void (*resume)(void); +}; + +bool hypervisor_probe(void); +void hypervisor_setup(void); +void hypervisor_ap_setup(void); +void hypervisor_resume(void); + +#else + +#include + +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) {} + +#endif /* CONFIG_GUEST */ + +#endif /* __X86_HYPERVISOR_H__ */ + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/xen/include/asm-x86/guest/xen.h b/xen/include/asm-x86/guest/xe= n.h index b015ed1883..3145f75361 100644 --- a/xen/include/asm-x86/guest/xen.h +++ b/xen/include/asm-x86/guest/xen.h @@ -33,11 +33,8 @@ extern bool pv_console; extern uint32_t xen_cpuid_base; =20 void probe_hypervisor(void); -void hypervisor_setup(void); -void hypervisor_ap_setup(void); int hypervisor_alloc_unused_page(mfn_t *mfn); int hypervisor_free_unused_page(mfn_t mfn); -void hypervisor_resume(void); =20 DECLARE_PER_CPU(unsigned int, vcpu_id); DECLARE_PER_CPU(struct vcpu_info *, vcpu_info); @@ -49,15 +46,6 @@ DECLARE_PER_CPU(struct vcpu_info *, vcpu_info); =20 static inline void probe_hypervisor(void) {} =20 -static inline void hypervisor_setup(void) -{ - ASSERT_UNREACHABLE(); -} -static inline void hypervisor_ap_setup(void) -{ - ASSERT_UNREACHABLE(); -} - #endif /* CONFIG_XEN_GUEST */ #endif /* __X86_GUEST_XEN_H__ */ =20 --=20 2.20.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel