From nobody Tue Apr 23 15:46:43 2024 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=1574362290; cv=none; d=zoho.com; s=zohoarc; b=F8iW54lxAOOXCZB76+7l301oakoSZO4MfxQ9LmBctal9A00aPqj/Q/aDg6RLGlSi77F4o2/oPPYjk6V8F1g8pBZavnQcBIF4hZk1fCqlONyi44f2wOrFKoem26BkLnFBxQ2cGAH/xk+UkkCcuZzNmFL/iXaE8Xi6wtdwtwyWa0k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1574362290; 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=DyP5SYrqxRRfNyH5e+B9Jx/PpbvhWl9uzkMDz6Q+pNI=; b=SsVTdOPrtKbLdWJMl3xWj7n9shad03fPOedc751bUCBrVpzgLrMmpt9q+SsCZboNJznH5Q3/I2TTD40x/mnYkhQgdV3x18PLzYseKbaHf6CfPiqqORSdNrNVh/eYaozbCS17JnqzRSU0OKeaEjjCL57Xz9psNvdGyOs4r/YmlPg= 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 1574362290551545.0962222957206; Thu, 21 Nov 2019 10:51:30 -0800 (PST) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iXrXh-00075X-3H; Thu, 21 Nov 2019 18:51:01 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iXrXf-00075H-HH for xen-devel@lists.xenproject.org; Thu, 21 Nov 2019 18:50:59 +0000 Received: from mail-wm1-x343.google.com (unknown [2a00:1450:4864:20::343]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id d8aa9da2-0c8f-11ea-b678-bc764e2007e4; Thu, 21 Nov 2019 18:50:54 +0000 (UTC) Received: by mail-wm1-x343.google.com with SMTP id x26so4632768wmk.4 for ; Thu, 21 Nov 2019 10:50:54 -0800 (PST) Received: from debian.mshome.net (74.162.147.147.dyn.plus.net. [147.147.162.74]) by smtp.gmail.com with ESMTPSA id f24sm535776wmb.37.2019.11.21.10.50.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Nov 2019 10:50:53 -0800 (PST) X-Inumbo-ID: d8aa9da2-0c8f-11ea-b678-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=TWXlLe8IMt8Vs7gsl166Q3OWJ9VnuTA9ivSeF58Db7o=; b=Pvdmzp5f8fRFrvPbU0D9OD+MEjNkTmryCmBaKT+A1mWiEy6zYgiGbrgkfvu6+ib6do 8h1yaSsRgTTCtHgpfmECB4FZJYeGOS7cwASHx2EMoAqvgglYewMbv2dlfmubiPykwT5i FDHirMkogVDsUvy81GZDhyYS9eAUEccq5apRDYvLWMCG/vYQWsVkDm5WOBGaU1anjGVQ vAPgTH4Rsz52BlkyPEzYH9YeXPK/fqfW95vNrtz7l4h/QLguNYnc4C3MyOy7c5gMOsOV /T3v/2ju6wOmv3nj4ViGSNp3EWuATKng6Hp44J0g5+3ha7RO0h0mz2MsEoY669ABaLxZ rfGg== 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=TWXlLe8IMt8Vs7gsl166Q3OWJ9VnuTA9ivSeF58Db7o=; b=gluMyTKzzVb64OvVKlNDPKUUdmps1KhojGPfgo5FkneQo9JCx861BOwbdQ4a3sNMZv RknZgRvC2EOSoqNQGt9k/LhNzOWuLno7Ym1hBOjjCsCYE9j6htteCsxggk2WdpZoZrUz mnpx+bw2lj+NJB9KuIz8UJTvPvFFxdt14Ha7gtfNfew/uALyxBFxPVsKPAeSif72EebF ijjQDf+2rfQcKR5oWpsOxPQh5I8w4LESrZYStUxjOnQyRXc1AUPurez4yYSxsI1pxSCC JkNBR4j708k8eZXndhpu6r1DBfLSD4giyJPU8zhqlXBXlbqohSN905E8hgcsh5GqWt07 G42Q== X-Gm-Message-State: APjAAAXJgvd7EJcBsYkyyAi0mCbSjlwsTKSFeAG3DXnV6yAw9mT0nGoQ iti2dOHxAGcjNN6RjYLpcwIFJcyYJnI3KQ== X-Google-Smtp-Source: APXvYqzcAwIjDfYAE9dxx/6OVltsNTt4lT61svhWwLga+wa9Q0feppnp4da7WQE245eMH0hXromtEA== X-Received: by 2002:a05:600c:cf:: with SMTP id u15mr11982474wmm.60.1574362253803; Thu, 21 Nov 2019 10:50:53 -0800 (PST) From: Wei Liu X-Google-Original-From: Wei Liu To: Xen Development List Date: Thu, 21 Nov 2019 18:50:42 +0000 Message-Id: <20191121185049.16666-2-liuwe@microsoft.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191121185049.16666-1-liuwe@microsoft.com> References: <20191121185049.16666-1-liuwe@microsoft.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v4 1/8] x86: introduce CONFIG_GUEST and move code 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) Xen is able to run as a guest on Xen. We plan to make it able to run on Hyper-V as well. Introduce CONFIG_GUEST which is set to true if either running on Xen or Hyper-V is desired. Restructure code hierarchy for new code to come. No functional change intended. Signed-off-by: Wei Liu Reviewed-by: Roger Pau Monn=C3=A9 Acked-by: Jan Beulich --- xen/arch/x86/Kconfig | 4 ++++ xen/arch/x86/Makefile | 2 +- xen/arch/x86/guest/Makefile | 5 +---- xen/arch/x86/guest/xen/Makefile | 4 ++++ xen/arch/x86/guest/{ =3D> xen}/hypercall_page.S | 0 xen/arch/x86/guest/{ =3D> xen}/pvh-boot.c | 0 xen/arch/x86/guest/{ =3D> xen}/xen.c | 0 7 files changed, 10 insertions(+), 5 deletions(-) create mode 100644 xen/arch/x86/guest/xen/Makefile rename xen/arch/x86/guest/{ =3D> xen}/hypercall_page.S (100%) rename xen/arch/x86/guest/{ =3D> xen}/pvh-boot.c (100%) rename xen/arch/x86/guest/{ =3D> xen}/xen.c (100%) diff --git a/xen/arch/x86/Kconfig b/xen/arch/x86/Kconfig index 28b3b4692a..867de857e8 100644 --- a/xen/arch/x86/Kconfig +++ b/xen/arch/x86/Kconfig @@ -161,8 +161,12 @@ config XEN_ALIGN_2M =20 endchoice =20 +config GUEST + bool + config XEN_GUEST def_bool n + select GUEST prompt "Xen Guest" ---help--- Support for Xen detecting when it is running under Xen. diff --git a/xen/arch/x86/Makefile b/xen/arch/x86/Makefile index a0b2f4ab15..7da5a2631e 100644 --- a/xen/arch/x86/Makefile +++ b/xen/arch/x86/Makefile @@ -1,7 +1,7 @@ subdir-y +=3D acpi subdir-y +=3D cpu subdir-y +=3D genapic -subdir-$(CONFIG_XEN_GUEST) +=3D guest +subdir-$(CONFIG_GUEST) +=3D guest subdir-$(CONFIG_HVM) +=3D hvm subdir-y +=3D mm subdir-$(CONFIG_XENOPROF) +=3D oprofile diff --git a/xen/arch/x86/guest/Makefile b/xen/arch/x86/guest/Makefile index 26fb4b1007..6806f04947 100644 --- a/xen/arch/x86/guest/Makefile +++ b/xen/arch/x86/guest/Makefile @@ -1,4 +1 @@ -obj-y +=3D hypercall_page.o -obj-y +=3D xen.o - -obj-bin-$(CONFIG_PVH_GUEST) +=3D pvh-boot.init.o +subdir-$(CONFIG_XEN_GUEST) +=3D xen diff --git a/xen/arch/x86/guest/xen/Makefile b/xen/arch/x86/guest/xen/Makef= ile new file mode 100644 index 0000000000..26fb4b1007 --- /dev/null +++ b/xen/arch/x86/guest/xen/Makefile @@ -0,0 +1,4 @@ +obj-y +=3D hypercall_page.o +obj-y +=3D xen.o + +obj-bin-$(CONFIG_PVH_GUEST) +=3D pvh-boot.init.o diff --git a/xen/arch/x86/guest/hypercall_page.S b/xen/arch/x86/guest/xen/h= ypercall_page.S similarity index 100% rename from xen/arch/x86/guest/hypercall_page.S rename to xen/arch/x86/guest/xen/hypercall_page.S diff --git a/xen/arch/x86/guest/pvh-boot.c b/xen/arch/x86/guest/xen/pvh-boo= t.c similarity index 100% rename from xen/arch/x86/guest/pvh-boot.c rename to xen/arch/x86/guest/xen/pvh-boot.c diff --git a/xen/arch/x86/guest/xen.c b/xen/arch/x86/guest/xen/xen.c similarity index 100% rename from xen/arch/x86/guest/xen.c rename to xen/arch/x86/guest/xen/xen.c --=20 2.20.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Tue Apr 23 15:46:43 2024 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=1574362299; cv=none; d=zoho.com; s=zohoarc; b=ODwX82eduioQLWXtFzF3ezfsIETdWjrm7IsIi1W6pHD7CWuvxJNdR+IgJyTsHVWxj3Ez+0Ua0nDktVmPMxIJOSjQibs5DuFyd91vG+YH0OOw1Z1Mdkex2NQtoQAu31g/+MX2nalhRFCOP4NlJ+IhoeEcoS7eFW9NMgxj3ZLfq5Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1574362299; 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=uFP1Yk21hp662wdL5u4SIdzKdfWFlfzvIkYWq51M+Rc=; b=bXKTt6Dw73C7nFBN++BmugXMSMoB+STbytkfvdYpkBPDaXHpcxdVx8BROfq7MI1IFfGXTZi47+oa0tynydUdK1Qq5Y+e2d/WrtV8jyDgH3gsKFytNopbcd8nkUWtiTKYwXCZ2oAH5Ux+s56C0MKL08Q6vSZn+I0959Jb72Rzr5U= 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 1574362299737131.84569087488; Thu, 21 Nov 2019 10:51:39 -0800 (PST) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iXrXm-00077v-C6; Thu, 21 Nov 2019 18:51:06 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iXrXk-00077T-Gt for xen-devel@lists.xenproject.org; Thu, 21 Nov 2019 18:51:04 +0000 Received: from mail-wm1-x343.google.com (unknown [2a00:1450:4864:20::343]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id d92cbae4-0c8f-11ea-984a-bc764e2007e4; Thu, 21 Nov 2019 18:50:55 +0000 (UTC) Received: by mail-wm1-x343.google.com with SMTP id z19so4949797wmk.3 for ; Thu, 21 Nov 2019 10:50:55 -0800 (PST) Received: from debian.mshome.net (74.162.147.147.dyn.plus.net. [147.147.162.74]) by smtp.gmail.com with ESMTPSA id f24sm535776wmb.37.2019.11.21.10.50.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Nov 2019 10:50:54 -0800 (PST) X-Inumbo-ID: d92cbae4-0c8f-11ea-984a-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=AVP+NJX1jO0Cy8PowYlfCy2l9JmfmeIKdgyamebmLNw=; b=aAHIi/e5LtMoayj7tGilDgpdBQr4RlCktll+EQR43dc4AV4yygEVRZN6hkf9MWvf/j AzuSv3LbZ+i669P0aEvJ5hi23S1rkKUuLrlTQFNto+36213XX7J0d9gmsVqoj2kAjmGy WB58MYUmXmLDK4ToGP9mXxskvqQJ1pABDwoM+SrJOm2tfz/hg3yIVhuk7ZG/2cSdoDoc fRaEboUlycB0nuflMMaBBO3wRyjNZQq6fpBIKLwX5WQ+f4uDhqCOuo/3nczgb7A+lWuh 7EkCdF+2J39iWza3y+wDceXQQe0tBmU74miU5pCeZMUTpvGXpKJxqm9rll3jMsckv3hD sAdg== 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=AVP+NJX1jO0Cy8PowYlfCy2l9JmfmeIKdgyamebmLNw=; b=Jo9rKn1z7TA+9wHDzwbhX3fgDdCQ0UCdqUNsdLgAjK+ww0sJG7Dx7lzS4rLKGVq8df gIBEMo2Lof9UXMlQXGGjsmC4i7rhkUhCSq43xSeiLWhSj1meXKfCKiR1StTvSX8FsGto 1kj/mFv5/Kcez9Eo/RxJnlZxkC5zOMMQ34xHNS1uuFASKPoHK82f5ACDTrpiUzohsRG7 jh1em5orPS04xwM/OTC9QPwbXXZyDY+slzl6J1Mt4afevm0TVFCx47mAS+YzV7a1CLx+ xPHapRqUQEQ9UroJwbka1EE3rZLIGBqJyKvzC7157A6KMIaU9jd8JD2o7yJK2+MySQ0u zgbw== X-Gm-Message-State: APjAAAU1H9YKpgw8LnMVSHtZ9+d++4ScvErJYCQBMMcEW6c/K2j5sHUN s6E2mxB4yqidb41XnCPkh3YUGcojC73XJQ== X-Google-Smtp-Source: APXvYqzCeoi4LGaaxplQwDkcNx2KLl9bSrOW3C4CPXLXFkT2mpp1d53NoMf88EclnsNVBawgA+L66w== X-Received: by 2002:a05:600c:214a:: with SMTP id v10mr11865344wml.102.1574362254710; Thu, 21 Nov 2019 10:50:54 -0800 (PST) From: Wei Liu X-Google-Original-From: Wei Liu To: Xen Development List Date: Thu, 21 Nov 2019 18:50:43 +0000 Message-Id: <20191121185049.16666-3-liuwe@microsoft.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191121185049.16666-1-liuwe@microsoft.com> References: <20191121185049.16666-1-liuwe@microsoft.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v4 2/8] x86: add missing headers in hypercall.h 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) Include asm_defns.h because ASM_CALL_CONSTRAINT is defined there. Include xen/lib.h because we need ASSERT_UNREACHABLE. No functional change. Signed-off-by: Wei Liu Reviewed-by: Roger Pau Monn=C3=A9 Acked-by: Jan Beulich --- xen/include/asm-x86/guest/hypercall.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/xen/include/asm-x86/guest/hypercall.h b/xen/include/asm-x86/gu= est/hypercall.h index d548816b30..d0d2f5022d 100644 --- a/xen/include/asm-x86/guest/hypercall.h +++ b/xen/include/asm-x86/guest/hypercall.h @@ -23,6 +23,8 @@ =20 #include =20 +#include + #include #include #include @@ -180,6 +182,8 @@ static inline long xen_hypercall_set_evtchn_upcall_vect= or( =20 #else /* CONFIG_XEN_GUEST */ =20 +#include + #include =20 static inline void xen_hypercall_console_write( --=20 2.20.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Tue Apr 23 15:46:43 2024 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=1574362301; cv=none; d=zoho.com; s=zohoarc; b=JZnDVxB+neGXoyQqRBPShw0nDLXXy5Gp5TKEJPSLZDXns2/w1jeUbJWjCWUi8qd/oRsalAwjeNehqZwzJ9h58kbvrZg2a+urVCT4HeUGvFw+ZS1aq+7lQwgGSKz8OSzFg0fEz7HG2ucWU4eAFZLMCfq8Wc2WpSWdznaQq/qRZk8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1574362301; 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=dnf/w5D/h/G8R9tO4TiV3vtmc+LxCRiejuf7+Y1KuIA=; b=HvYe6DuZlX/P1Cy72IYwxKXWkS3QCP04kLPYV+S42OK9mBkJmi3Rso5QixIhKbadu++Ws6g0Gq0pofTw0rohbtc9qCFecUh7WFPkWgxoit+2ByhPEEXOHA+x3Ud+xrvkiUmIKkJJbQN70hnR5HmIGUKJtNNHed2FhRwyutLN0yE= 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 157436230193455.89403783031628; Thu, 21 Nov 2019 10:51:41 -0800 (PST) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iXrXq-00079i-LS; Thu, 21 Nov 2019 18:51:10 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iXrXp-00079E-H5 for xen-devel@lists.xenproject.org; Thu, 21 Nov 2019 18:51:09 +0000 Received: from mail-wm1-x343.google.com (unknown [2a00:1450:4864:20::343]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id d9ae429e-0c8f-11ea-9631-bc764e2007e4; Thu, 21 Nov 2019 18:50:56 +0000 (UTC) Received: by mail-wm1-x343.google.com with SMTP id 8so4976338wmo.0 for ; Thu, 21 Nov 2019 10:50:56 -0800 (PST) Received: from debian.mshome.net (74.162.147.147.dyn.plus.net. [147.147.162.74]) by smtp.gmail.com with ESMTPSA id f24sm535776wmb.37.2019.11.21.10.50.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Nov 2019 10:50:55 -0800 (PST) X-Inumbo-ID: d9ae429e-0c8f-11ea-9631-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=Lp9dPk3GM26kCtmFBzgGz5LRW9FjTOSuocsi0vK/bvk=; b=M1VN5GGn93czJvTTl+fj7NTjiG3P7jMs/1rkeDf179J8kuqTVGZs7xhRKM7aATjbas bx0aJlgXf42VZdqri4tsmaFqSxfW6a6cO7RuK0q01DjQMlaOW1tLjW+ync9RGheIdtTU hro3h72Z+uDgENzrA3aoBqb/frQiyBCD6lYgNeZVoSZ762TJFSvpgC0rP4DUDFRYqFzf F28TEFSbgKh69AIFjcIF9Gtv62HgHijVDrlWKnmyjbcC3jhaWpZX55CDe9MmMtlv8KPA bQFYxLZq9arFgX6pJFw1Teq1vG/wxRTNP5Sikvo9urUJV7PcmojjfgWpDXZHPoq6Zvtf u4tQ== 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=Lp9dPk3GM26kCtmFBzgGz5LRW9FjTOSuocsi0vK/bvk=; b=rwscPIfZKMSAeunbpRQ51v6xDFEECXxgGmTCCL8sZ93c6kg/Ol4q70CdXeGnfAZ6AU 84gcPR9MHV7pbkkeLn04kNF/aIhSm0qcK4uKLoZNvpMMqo87GEHKXMCb4JwNloQoYSR0 a9moS/B9OotgsqVXEe1LDfzkTh4hrPS4QgxQG55+5tLKs41y5xAYa9O43kJWVqfsNDcK 4d2TLr3Gfqjgj977CV+6VLa88UxqoOoWxzYkdo8VF6O6q5bG/MJbvKT3JjoHgQ+/pA1u i/w/RrwQjTu/BuSlfYxajBNw0iTaspI8GlayYBu7KSWUNYp0W63srW0jm2la1D+ckW18 Fq2A== X-Gm-Message-State: APjAAAWjheBeoaSHgY6Kr47puEVqTR1YxOBi2ibosYvNVRowjnHc2HNp y7Qf0CQiPUbuJySHvoEipQ67WCgf0PN3Hg== X-Google-Smtp-Source: APXvYqxY9CZw7Zu4d0X3lbKELMD8ElPRO/vIXGm2iiBNVWhMiWLSNjHar5PZEfJG9BOCtGnmcly8gQ== X-Received: by 2002:a05:600c:2911:: with SMTP id i17mr11678800wmd.83.1574362255514; Thu, 21 Nov 2019 10:50:55 -0800 (PST) From: Wei Liu X-Google-Original-From: Wei Liu To: Xen Development List Date: Thu, 21 Nov 2019 18:50:44 +0000 Message-Id: <20191121185049.16666-4-liuwe@microsoft.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191121185049.16666-1-liuwe@microsoft.com> References: <20191121185049.16666-1-liuwe@microsoft.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v4 3/8] x86: drop hypervisor_cpuid_base 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) The only user is Xen specific code in PV shim. We can therefore export the variable directly. Move __read_mostly to its standard place while at it. Signed-off-by: Wei Liu Reviewed-by: Roger Pau Monn=C3=A9 Acked-by: Jan Beulich --- xen/arch/x86/guest/xen/xen.c | 7 +------ xen/arch/x86/pv/shim.c | 2 +- xen/include/asm-x86/guest/xen.h | 2 +- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/xen/arch/x86/guest/xen/xen.c b/xen/arch/x86/guest/xen/xen.c index a329e7c886..1e37086518 100644 --- a/xen/arch/x86/guest/xen/xen.c +++ b/xen/arch/x86/guest/xen/xen.c @@ -37,7 +37,7 @@ =20 bool __read_mostly xen_guest; =20 -static __read_mostly uint32_t xen_cpuid_base; +uint32_t __read_mostly xen_cpuid_base; extern char hypercall_page[]; static struct rangeset *mem; =20 @@ -297,11 +297,6 @@ int hypervisor_free_unused_page(mfn_t mfn) return rangeset_remove_range(mem, mfn_x(mfn), mfn_x(mfn)); } =20 -uint32_t hypervisor_cpuid_base(void) -{ - return xen_cpuid_base; -} - static void ap_resume(void *unused) { map_vcpuinfo(); diff --git a/xen/arch/x86/pv/shim.c b/xen/arch/x86/pv/shim.c index 35bf3945ac..351da970ef 100644 --- a/xen/arch/x86/pv/shim.c +++ b/xen/arch/x86/pv/shim.c @@ -995,7 +995,7 @@ domid_t get_initial_domain_id(void) if ( !pv_shim ) return 0; =20 - cpuid(hypervisor_cpuid_base() + 4, &eax, &ebx, &ecx, &edx); + cpuid(xen_cpuid_base + 4, &eax, &ebx, &ecx, &edx); =20 return (eax & XEN_HVM_CPUID_DOMID_PRESENT) ? ecx : 1; } diff --git a/xen/include/asm-x86/guest/xen.h b/xen/include/asm-x86/guest/xe= n.h index 7e04e4a7ab..b015ed1883 100644 --- a/xen/include/asm-x86/guest/xen.h +++ b/xen/include/asm-x86/guest/xen.h @@ -30,13 +30,13 @@ =20 extern bool xen_guest; 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); -uint32_t hypervisor_cpuid_base(void); void hypervisor_resume(void); =20 DECLARE_PER_CPU(unsigned int, vcpu_id); --=20 2.20.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Tue Apr 23 15:46:43 2024 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=1574362306; cv=none; d=zoho.com; s=zohoarc; b=A4SM2O2y0R8JQEr6Ac25K1ptIpAbH6Lica5FefUsov4WrzClijkJ8BFhOgGZSuFpqh+r9E/BjQTBBj2k6dFDJxOH738H2AwtAZkaQ154YylN9BvQmywfALsJqQVuvLe82JEdVGPGs2lCDx89jUP95AJHqfIcJTx0t22CQUasnq4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1574362306; 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=1PCsXvgr3OH5hiTf36c8yUSJiHlnqmIkhmP42JPAejM=; b=jMtKZGLU2OgdojOWuShqoToUhUFgdD0fEPU88OuI3gVCyWUTfKAa4+pPlcTf8y9oS1JwTeRl9wbDulLwEY0UyhWFURpkgq1DjniOXr+8FXpOxJHtvlrbAasTqVzwi9nuuj3Fbo1y961zg4UDjHRIxKzXhVWRFMNrHQsYK3EQDsQ= 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 1574362306326375.3961587158816; Thu, 21 Nov 2019 10:51:46 -0800 (PST) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iXrXv-0007Bi-0k; Thu, 21 Nov 2019 18:51:15 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iXrXu-0007BR-IG for xen-devel@lists.xenproject.org; Thu, 21 Nov 2019 18:51:14 +0000 Received: from mail-wm1-x344.google.com (unknown [2a00:1450:4864:20::344]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id da4a6124-0c8f-11ea-9631-bc764e2007e4; Thu, 21 Nov 2019 18:50:57 +0000 (UTC) Received: by mail-wm1-x344.google.com with SMTP id y5so4925090wmi.5 for ; Thu, 21 Nov 2019 10:50:57 -0800 (PST) Received: from debian.mshome.net (74.162.147.147.dyn.plus.net. [147.147.162.74]) by smtp.gmail.com with ESMTPSA id f24sm535776wmb.37.2019.11.21.10.50.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Nov 2019 10:50:55 -0800 (PST) X-Inumbo-ID: da4a6124-0c8f-11ea-9631-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=xiGjljNkC4GMr6WhYgoC6GU6XAbJmyqyEGay//B9pSA=; b=l0gZX27w0zztTLh2ZsWezxGTJDQB5XfFLYod2uW+lAv8fVH+FTO75y+6D72Idmef+c dQXp60VdCmOU6tdbFwQCXl7X6NizqWwAsMmKVZn/M6oHvtDffmkd3CKy8YW0PLCL5kTH oX0+ZJ8T6mUasYFECiQ1Sw1bXdPAAhHFr9KgKxA2vI1bnGWBC8nGneyx7Wj1KrSkJBwj oZCy16556Ak1YTqBBuRxUPgwb5pfDrNH6VxXPcOpwYArgmdo1Vbq1AqFywZZPA3kqyLY 9Y+ZtfhSh/r9xlxsccule35AAO/XzJMNOYP9I0lNEBb9VF47qq9sYQEk0RCkK1zqmmjZ hXNQ== 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=xiGjljNkC4GMr6WhYgoC6GU6XAbJmyqyEGay//B9pSA=; b=D8m3wDFgLqpLR8Iszuy5/+Rhggicju5snIoptLkAcFtmZH6NxF57UL5wRgJzFff+ZX GwwIp2fH54V5gtKchV/K66C7d/AJOqLtkiPRy1vysQmr1qkMxYb3Y+UWoxKRKNWUBa69 kG7ZaN2eEvb6fsNiXyn5/ly36O6fHFr61WG03TowoTCm6QS5TNwyK0PZyIFYcDLudHVc b2ci+QMIvoFqbdE4zeW5JVjDpGWoac1KsKPmuQanZlJknW4BAxM+NisT9ld7wlBE/oFO jqJXMV91vfatc5vfzC53p8lZjUZUNCu7cpxv0z4MYisjy76A7vcqes0eZ6fUCuzBns2L y8pw== X-Gm-Message-State: APjAAAUGLFDqw/PG915mqIfHk+UqqyepFkm2MME/J1n3yoQ7XrkUV/Bj Sty8rYOLSM8QF5U560GTNhEdc1IG6VbRsg== X-Google-Smtp-Source: APXvYqyQyJUyVftDjzujhh2yZGPXnKho94yS+Q/NYalTUSPOE3Yl99WpzEZ+Q3nUjjhg1WviuRnMcQ== X-Received: by 2002:a7b:c307:: with SMTP id k7mr11086092wmj.134.1574362256443; Thu, 21 Nov 2019 10:50:56 -0800 (PST) From: Wei Liu X-Google-Original-From: Wei Liu To: Xen Development List Date: Thu, 21 Nov 2019 18:50:45 +0000 Message-Id: <20191121185049.16666-5-liuwe@microsoft.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191121185049.16666-1-liuwe@microsoft.com> References: <20191121185049.16666-1-liuwe@microsoft.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v4 4/8] 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 --- Changes in v4: 1. Add ASSERT_UNREACHABLE to stubs. 2. Move __read_mostly. 3. Return hops directly. 4. Drop Paul's review tag. --- xen/arch/x86/guest/Makefile | 2 + xen/arch/x86/guest/hypervisor.c | 42 +++++++++++++++++ xen/include/asm-x86/guest.h | 1 + xen/include/asm-x86/guest/hypervisor.h | 62 ++++++++++++++++++++++++++ xen/include/asm-x86/guest/xen.h | 12 ----- 5 files changed, 107 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..103feba5d8 --- /dev/null +++ b/xen/arch/x86/guest/hypervisor.c @@ -0,0 +1,42 @@ +/*************************************************************************= ***** + * 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 const struct hypervisor_ops __read_mostly *hops; + +const struct hypervisor_ops *hypervisor_probe(void) +{ + return hops; +} + +/* + * 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..2ab15a7108 --- /dev/null +++ b/xen/include/asm-x86/guest/hypervisor.h @@ -0,0 +1,62 @@ +/*************************************************************************= ***** + * 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__ + +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); +}; + +#ifdef CONFIG_GUEST + +const struct hypervisor_ops *hypervisor_probe(void); +void hypervisor_setup(void); +void hypervisor_ap_setup(void); +void hypervisor_resume(void); + +#else + +#include +#include + +static inline const struct hypervisor_ops *hypervisor_probe(void) { return= NULL; } +static inline void hypervisor_setup(void) { ASSERT_UNREACHABLE(); } +static inline void hypervisor_ap_setup(void) { ASSERT_UNREACHABLE(); } +static inline void hypervisor_resume(void) { ASSERT_UNREACHABLE(); } + +#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 From nobody Tue Apr 23 15:46:43 2024 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=1574362308; cv=none; d=zoho.com; s=zohoarc; b=WClFKBP3rMmQvyP5s6cyK+UoEf6W5niEYMKhmV808IDtHN+nRw9a3f3mBocegNJ6+T2oNrHBtNjTCPpYYQCUlFMApBNZQKjIglYa78Vp0BFnDtusTGeBEVbSMADH+37pRnMp/1XLnGe1bsngjztbG690OX9XD8jtUeblmifPU5Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1574362308; 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=Q+N0E/sWnJ8D3p2lqzOdkCQBqjwG8U5+WF1cw4siQNE=; b=YXQOFLrowzTgO0iPaNg5yFs7XP/tIC5cSr1kNKQKasqdvhKMEQqNASrgx8coidPHG/bH7+N2gGutyx2XtYZq7EvBVNqCVzT9T5pK0kHgMJ+/SgU7OKPTG9XEKxDD0GbO8SflHOkyhnesyIHQAuq2m9vOCsdLUmcdwA/kih1n98g= 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 1574362308359161.27428393715604; Thu, 21 Nov 2019 10:51:48 -0800 (PST) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iXrY0-0007Ef-E7; Thu, 21 Nov 2019 18:51:20 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iXrXz-0007EH-HY for xen-devel@lists.xenproject.org; Thu, 21 Nov 2019 18:51:19 +0000 Received: from mail-wm1-x32d.google.com (unknown [2a00:1450:4864:20::32d]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id dab75856-0c8f-11ea-9631-bc764e2007e4; Thu, 21 Nov 2019 18:50:58 +0000 (UTC) Received: by mail-wm1-x32d.google.com with SMTP id u18so4928858wmc.3 for ; Thu, 21 Nov 2019 10:50:58 -0800 (PST) Received: from debian.mshome.net (74.162.147.147.dyn.plus.net. [147.147.162.74]) by smtp.gmail.com with ESMTPSA id f24sm535776wmb.37.2019.11.21.10.50.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Nov 2019 10:50:56 -0800 (PST) X-Inumbo-ID: dab75856-0c8f-11ea-9631-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=LK3O/o3+V3DHJGhpDMqiDmW/Ssr7NmvU9isr2SCzc0w=; b=ptxXAqqy8ro3dJL4t/nSoN1+6hRmBkHjzvFQ6bnfQInHK85Zsebpy1US9d5CNxDJcJ yU2E61X+Ys4dW33ov3X7t5quLCXGY5WOlg4fP/8OnSzciX87gm9Q087EjyvUs1RVsQpL wUmHbuxDk+mEEO8Kj9s/mARhugYhygJMSKd6W1EzpRc2m92uRdXDD8P2GMB6Vwql9yvN QsIUNFuHJFvZeICz7juxFCQPi3RQq2+n1l6Ioiyo1FFgMpD7NxhllOzeoTJq+US/0NS1 sqMgEb5xgvFXPOljXYJyTx8tKDhJhzbmssiLixprTIQcbeE8gUQ/4C0KvEHuLWfUT1gv 1k3A== 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=LK3O/o3+V3DHJGhpDMqiDmW/Ssr7NmvU9isr2SCzc0w=; b=olLux41gkg1cj2Da1pLPPxr/MooM9ZVOBgfkpdqPoV+P3sAFesK+2J1f4QcR61I8lw jeaO+O5itg/+JInIVLQJAW2z5A54pxbzQOQu4lC0MF/u6+TC5EyZ1j4mTq1ICsAQnWSn zZ2e6u268/VFNCoZNlGTThjR2WW9x3WhkHFID0NTUWwgZDfamAwECtlZ7MhVrPOGJVzB p2JUNx1JdgWHN59508j70UpNEjnFPjbrmj7swFcDknwLGJ8DjLELWyhUMI74D907QVZV Xl+EdLTuWk8Q2HaqvGf0+EoZus/CGwFaZ1d439sUOwc4CypSj/MG58bJ3uSCMB81oTV9 JVog== X-Gm-Message-State: APjAAAXtoDPv4oEjyRiFEN8+IQuIi/CMYeb8LspeTttKm2O7wwNhl9r5 8Vve56EqVz+IdNUQhJUqShIwU8cJCP/3yA== X-Google-Smtp-Source: APXvYqxWVpXt/Qc0C0cAUMlzaVQmPeT7b7SzY5KpY5MsUpZ+UblLnhPUVoKTy2oNPFEsWfnK6ebi3g== X-Received: by 2002:a1c:a512:: with SMTP id o18mr11419892wme.4.1574362257271; Thu, 21 Nov 2019 10:50:57 -0800 (PST) From: Wei Liu X-Google-Original-From: Wei Liu To: Xen Development List Date: Thu, 21 Nov 2019 18:50:46 +0000 Message-Id: <20191121185049.16666-6-liuwe@microsoft.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191121185049.16666-1-liuwe@microsoft.com> References: <20191121185049.16666-1-liuwe@microsoft.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v4 5/8] x86: rename hypervisor_{alloc, free}_unused_page 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) They are used in Xen code only. No functional change. Signed-off-by: Wei Liu --- Changes in v4: 1. Use xg_ prefix instead. 2. Drop Roger's review tag. --- xen/arch/x86/guest/xen/xen.c | 6 +++--- xen/arch/x86/pv/shim.c | 4 ++-- xen/include/asm-x86/guest/xen.h | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/xen/arch/x86/guest/xen/xen.c b/xen/arch/x86/guest/xen/xen.c index 1e37086518..0f5b5267c5 100644 --- a/xen/arch/x86/guest/xen/xen.c +++ b/xen/arch/x86/guest/xen/xen.c @@ -93,7 +93,7 @@ static void map_shared_info(void) unsigned int i; unsigned long rc; =20 - if ( hypervisor_alloc_unused_page(&mfn) ) + if ( xg_alloc_unused_page(&mfn) ) panic("unable to reserve shared info memory page\n"); =20 xatp.gpfn =3D mfn_x(mfn); @@ -280,7 +280,7 @@ void hypervisor_ap_setup(void) init_evtchn(); } =20 -int hypervisor_alloc_unused_page(mfn_t *mfn) +int xg_alloc_unused_page(mfn_t *mfn) { unsigned long m; int rc; @@ -292,7 +292,7 @@ int hypervisor_alloc_unused_page(mfn_t *mfn) return rc; } =20 -int hypervisor_free_unused_page(mfn_t mfn) +int xg_free_unused_page(mfn_t mfn) { return rangeset_remove_range(mem, mfn_x(mfn), mfn_x(mfn)); } diff --git a/xen/arch/x86/pv/shim.c b/xen/arch/x86/pv/shim.c index 351da970ef..7a898fdbe5 100644 --- a/xen/arch/x86/pv/shim.c +++ b/xen/arch/x86/pv/shim.c @@ -742,7 +742,7 @@ static long pv_shim_grant_table_op(unsigned int cmd, }; mfn_t mfn; =20 - rc =3D hypervisor_alloc_unused_page(&mfn); + rc =3D xg_alloc_unused_page(&mfn); if ( rc ) { gprintk(XENLOG_ERR, @@ -754,7 +754,7 @@ static long pv_shim_grant_table_op(unsigned int cmd, rc =3D xen_hypercall_memory_op(XENMEM_add_to_physmap, &xat= p); if ( rc ) { - hypervisor_free_unused_page(mfn); + xg_free_unused_page(mfn); break; } =20 diff --git a/xen/include/asm-x86/guest/xen.h b/xen/include/asm-x86/guest/xe= n.h index 3145f75361..01dc3ee6f6 100644 --- a/xen/include/asm-x86/guest/xen.h +++ b/xen/include/asm-x86/guest/xen.h @@ -33,8 +33,8 @@ extern bool pv_console; extern uint32_t xen_cpuid_base; =20 void probe_hypervisor(void); -int hypervisor_alloc_unused_page(mfn_t *mfn); -int hypervisor_free_unused_page(mfn_t mfn); +int xg_alloc_unused_page(mfn_t *mfn); +int xg_free_unused_page(mfn_t mfn); =20 DECLARE_PER_CPU(unsigned int, vcpu_id); DECLARE_PER_CPU(struct vcpu_info *, vcpu_info); --=20 2.20.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Tue Apr 23 15:46:43 2024 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=1574362313; cv=none; d=zoho.com; s=zohoarc; b=Fyqkc6scvE2Fui9bCC8A9k0l7uPGFEgE6pEKYOhYDO6WlkjwS0qtwi//IYdCgkBJVEgH/QRK/e0/KoyffzEsw3gj1LRzwXlA63CEvcZx8cTRIh9Bt2XVugvaffGUNsxnPqKYQ/vWa+HwIABUJ2ufUXKQyT4ZgYdIFDcEbPUprfs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1574362313; 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=RlE7UpY4l3gurKMbikK5OEAHeL8EA5lz6fx9KFeAf2A=; b=X3KBmHdFJg52O5NxnAOLLvNa1ePuMOtu/xRxL7R8H4PBhYWgIuqbfU0wRK3Fk1S+1RZLxzI80WRV4sXr+Zf1NZDoXRhGZ2lop41WW5s4BdPij1I1L6aLv784UV2ZkPIrvkFWuZTKVj+4Oq4hkR2fLvfKSxP+zuZNzD2Zs/tnrf0= 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 157436231380714.631375478934388; Thu, 21 Nov 2019 10:51:53 -0800 (PST) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iXrY5-0007Hc-Mr; Thu, 21 Nov 2019 18:51:25 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iXrY4-0007Gy-HE for xen-devel@lists.xenproject.org; Thu, 21 Nov 2019 18:51:24 +0000 Received: from mail-wr1-x442.google.com (unknown [2a00:1450:4864:20::442]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id db58437e-0c8f-11ea-adbe-bc764e2007e4; Thu, 21 Nov 2019 18:50:59 +0000 (UTC) Received: by mail-wr1-x442.google.com with SMTP id s5so5768410wrw.2 for ; Thu, 21 Nov 2019 10:50:59 -0800 (PST) Received: from debian.mshome.net (74.162.147.147.dyn.plus.net. [147.147.162.74]) by smtp.gmail.com with ESMTPSA id f24sm535776wmb.37.2019.11.21.10.50.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Nov 2019 10:50:57 -0800 (PST) X-Inumbo-ID: db58437e-0c8f-11ea-adbe-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=jmehIbWhQZXdoUxqvv2nAE9/O4n7ZGXTOOruyuVNHSs=; b=IkngiqlTkjNea7bGBPVnXACVbqM6xI4KEZgbGHD6t9H9M9yHG+zPD3jIN1fOEB1OgZ qRd3YBh4k0lSJvA+1t1IXQ19sxrAUgkxs9QU4ad4CipzpvCUpkd4/QjqIb3jtMHcrVkI Q2KlV3NvpdBVKtLnFwrTipM3FUpYQjtUixLFbspIcsLssNTfgXGgm3Ev5msgCgiGFvdF xrZiiTgsc1vrysTKaQfrXBu0VQ0nPO4zmH02W0a1XHgX/LUpDUzKDUTTbG+PDSNNsDc+ MTLTjoiKTTbJf1tKpuXjmf92usCZaAEMqFYnwYalBZJJcv4wq3rWz3sd8oYWfyPsmxjc +q7Q== 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=jmehIbWhQZXdoUxqvv2nAE9/O4n7ZGXTOOruyuVNHSs=; b=ESgvjMjaxbLflewmdLzKdjZdbFQSDn8T5wbBByq00lqpo67C2bWmRsGvz/QEiF/kxu DmiBgBvMhbHInl9W4RROHQfAQnXM3XdTEO53b/cU75kqo+kdUYv3FIR9uABgLVX4gZdk IU+6w1+3UNEGMsqYjJy5Lhdvv9Tt7uoUdrsx+fvOsXql3rN/ZjsKtCOn6TeyOi0AGNaF pV0liQVvxB1KofbuogtJ30JectwJUphzpRdPquIyfb2mSY7WJQHLAdE+7c4hCfixi9YC JMEfL+L/NyYJF4OwlQ2g/fUlHBmGM86zvcO3r651SALZ5uTkzPCLigsxzsNzfb+uISmW wlgQ== X-Gm-Message-State: APjAAAXZ8ex9l1D7pK21QnjvI+j9mhLkXCW/UpqE/Zb2ILF2qTfybkL9 QXCBIo0XWKMugpyJudZCq/JptQGa709uXw== X-Google-Smtp-Source: APXvYqy2zlru4pM8V+dttgjt7cGZa47POMDpLNWukAwn3g5e+CeRyvXcn5iZQ1t0HdIlg/zz8b+Law== X-Received: by 2002:adf:db51:: with SMTP id f17mr12500221wrj.85.1574362258219; Thu, 21 Nov 2019 10:50:58 -0800 (PST) From: Wei Liu X-Google-Original-From: Wei Liu To: Xen Development List Date: Thu, 21 Nov 2019 18:50:47 +0000 Message-Id: <20191121185049.16666-7-liuwe@microsoft.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191121185049.16666-1-liuwe@microsoft.com> References: <20191121185049.16666-1-liuwe@microsoft.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v4 6/8] x86: switch xen guest implementation to use 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) Signed-off-by: Wei Liu --- Changes in v4: 1. xen_probe returns address of ops directly. 2. Add __init to hypervisor_setup. 3. Drop Paul's review tag. --- xen/arch/x86/guest/hypervisor.c | 32 ++++++++++++++++++++- xen/arch/x86/guest/xen/pvh-boot.c | 2 +- xen/arch/x86/guest/xen/xen.c | 47 ++++++++++++++++++------------- xen/arch/x86/setup.c | 2 +- xen/include/asm-x86/guest/xen.h | 5 ++-- 5 files changed, 64 insertions(+), 24 deletions(-) diff --git a/xen/arch/x86/guest/hypervisor.c b/xen/arch/x86/guest/hyperviso= r.c index 103feba5d8..a067cacecb 100644 --- a/xen/arch/x86/guest/hypervisor.c +++ b/xen/arch/x86/guest/hypervisor.c @@ -19,18 +19,48 @@ * Copyright (c) 2019 Microsoft. */ =20 +#include #include =20 #include -#include +#include =20 static const struct hypervisor_ops __read_mostly *hops; =20 const struct hypervisor_ops *hypervisor_probe(void) { + if ( hops ) + goto out; + + if ( !cpu_has_hypervisor ) + goto out; + + hops =3D xen_probe(); + if ( hops ) + goto out; + + out: return hops; } =20 +void __init hypervisor_setup(void) +{ + if ( hops && hops->setup ) + hops->setup(); +} + +void hypervisor_ap_setup(void) +{ + if ( hops && hops->ap_setup ) + hops->ap_setup(); +} + +void hypervisor_resume(void) +{ + if ( hops && hops->resume ) + hops->resume(); +} + /* * Local variables: * mode: C diff --git a/xen/arch/x86/guest/xen/pvh-boot.c b/xen/arch/x86/guest/xen/pvh= -boot.c index ca8e156f7d..498625eae0 100644 --- a/xen/arch/x86/guest/xen/pvh-boot.c +++ b/xen/arch/x86/guest/xen/pvh-boot.c @@ -103,7 +103,7 @@ void __init pvh_init(multiboot_info_t **mbi, module_t *= *mod) { convert_pvh_info(mbi, mod); =20 - probe_hypervisor(); + hypervisor_probe(); ASSERT(xen_guest); =20 get_memory_map(); diff --git a/xen/arch/x86/guest/xen/xen.c b/xen/arch/x86/guest/xen/xen.c index 0f5b5267c5..8cfe059887 100644 --- a/xen/arch/x86/guest/xen/xen.c +++ b/xen/arch/x86/guest/xen/xen.c @@ -67,22 +67,6 @@ static void __init find_xen_leaves(void) } } =20 -void __init probe_hypervisor(void) -{ - if ( xen_guest || !cpu_has_hypervisor ) - return; - - find_xen_leaves(); - - if ( !xen_cpuid_base ) - return; - - /* Fill the hypercall page. */ - wrmsrl(cpuid_ebx(xen_cpuid_base + 2), __pa(hypercall_page)); - - xen_guest =3D true; -} - static void map_shared_info(void) { mfn_t mfn; @@ -245,7 +229,7 @@ static void init_evtchn(void) } } =20 -void __init hypervisor_setup(void) +static void __init xen_setup(void) { init_memmap(); =20 @@ -273,7 +257,7 @@ void __init hypervisor_setup(void) init_evtchn(); } =20 -void hypervisor_ap_setup(void) +static void xen_ap_setup(void) { set_vcpu_id(); map_vcpuinfo(); @@ -303,7 +287,7 @@ static void ap_resume(void *unused) init_evtchn(); } =20 -void hypervisor_resume(void) +static void xen_resume(void) { /* Reset shared info page. */ map_shared_info(); @@ -326,6 +310,31 @@ void hypervisor_resume(void) pv_console_init(); } =20 +static const struct hypervisor_ops xg_ops =3D { + .name =3D "Xen", + .setup =3D xen_setup, + .ap_setup =3D xen_ap_setup, + .resume =3D xen_resume, +}; + +const struct hypervisor_ops * __init xen_probe(void) +{ + if ( xen_guest ) + return &xg_ops; + + find_xen_leaves(); + + if ( !xen_cpuid_base ) + return NULL; + + /* Fill the hypercall page. */ + wrmsrl(cpuid_ebx(xen_cpuid_base + 2), __pa(hypercall_page)); + + xen_guest =3D true; + + return &xg_ops; +} + /* * Local variables: * mode: C diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 00ee87bde5..19606d909b 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -763,7 +763,7 @@ void __init noreturn __start_xen(unsigned long mbi_p) * allocing any xenheap structures wanted in lower memory. */ kexec_early_calculations(); =20 - probe_hypervisor(); + hypervisor_probe(); =20 parse_video_info(); =20 diff --git a/xen/include/asm-x86/guest/xen.h b/xen/include/asm-x86/guest/xe= n.h index 01dc3ee6f6..db90b550a7 100644 --- a/xen/include/asm-x86/guest/xen.h +++ b/xen/include/asm-x86/guest/xen.h @@ -23,6 +23,7 @@ =20 #include #include +#include =20 #define XEN_shared_info ((struct shared_info *)fix_to_virt(FIX_XEN_SHARED_= INFO)) =20 @@ -32,7 +33,7 @@ extern bool xen_guest; extern bool pv_console; extern uint32_t xen_cpuid_base; =20 -void probe_hypervisor(void); +const struct hypervisor_ops *xen_probe(void); int xg_alloc_unused_page(mfn_t *mfn); int xg_free_unused_page(mfn_t mfn); =20 @@ -44,7 +45,7 @@ DECLARE_PER_CPU(struct vcpu_info *, vcpu_info); #define xen_guest 0 #define pv_console 0 =20 -static inline void probe_hypervisor(void) {} +static inline const struct hypervisor_ops *xen_probe(void) { return NULL; } =20 #endif /* CONFIG_XEN_GUEST */ #endif /* __X86_GUEST_XEN_H__ */ --=20 2.20.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Tue Apr 23 15:46:43 2024 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=1574362317; cv=none; d=zoho.com; s=zohoarc; b=c66Bl3NH/1mlJCPqNLgXOWj+kHO7HrXKboTt2/1hp6g2RvlbiC9HOPnso1dQb2qWg1s7iXIfHixCTPrlEJxd3Ar9Li18RR0rnsligBHm1oZAooZeuTnQTXY6YhVVxjqKQYsS+/XXE89jOiSkO/0dSTjGrYgMHxOhOuoBkg8o35I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1574362317; 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=yp1bp54NQs26FyMIimYlTkQk7yI7siQV22u7KR+u3C0=; b=lmez/uNI/JYb9omlU/LWmX9KnAvExZDLWwjESVDnsrZhixInq0Po+TCMOdT0v+hrZTzdOXR2oRY46ih9fnb2hwcSfHwvMj2fzTLjUnXsM5WWeV8TyLQOflBNcMUVme8o18uv2qiGYfDKY4uKw8Z7+2bTUYo5qSyCm475mVoD3Wk= 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 1574362317431770.338980599497; Thu, 21 Nov 2019 10:51:57 -0800 (PST) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iXrYA-0007Kz-Vy; Thu, 21 Nov 2019 18:51:30 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iXrY9-0007K7-HP for xen-devel@lists.xenproject.org; Thu, 21 Nov 2019 18:51:29 +0000 Received: from mail-wr1-x443.google.com (unknown [2a00:1450:4864:20::443]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id dbd84f74-0c8f-11ea-b678-bc764e2007e4; Thu, 21 Nov 2019 18:51:00 +0000 (UTC) Received: by mail-wr1-x443.google.com with SMTP id i12so5746535wro.5 for ; Thu, 21 Nov 2019 10:51:00 -0800 (PST) Received: from debian.mshome.net (74.162.147.147.dyn.plus.net. [147.147.162.74]) by smtp.gmail.com with ESMTPSA id f24sm535776wmb.37.2019.11.21.10.50.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Nov 2019 10:50:58 -0800 (PST) X-Inumbo-ID: dbd84f74-0c8f-11ea-b678-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=lUPue3nJI1BlCj5R+fUwF507OE2ynKQH95Wp7cLyvA0=; b=rl9AWJu69RO7Wpww06KuYN/PM5btN7iuOVIeGur8pTn3ThpiikXCLuSUeESpH7pOD+ YboI4mcouxi6ygjjjew0iRLEscAlj4ySJtLiBoVd4mpNvULxDNf0J8cvUnO3u9cT17AS 6REDDnrqhkixYFlvbDoAL9DSZn2j3C86McitktZJpeDVaGToYgMLp30CrJm0IUa0/yWB 22hNGwzP1RyfmK2MuCDxEVH7qyj8gM0bTkLcImbjMUw1uZSKURIQDyBjjuu65DHwmoht EQP6Gboli/g/CE13o9Ryz4fju+G6x9cY+NPbXMQb1GB7fJn2ZvBGhRxRsodxYrD9gGn7 woCQ== 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=lUPue3nJI1BlCj5R+fUwF507OE2ynKQH95Wp7cLyvA0=; b=OrfWP5BQl5xAj0+vO6ORe220U+RUX98bs3ft0bl/qxiCgJf1M0iXoyzO6+QPfPm+Q4 sp2xRTo3X8SXsTbDDBS+15Kp6CSuB0Z42Ng7nBGL7rPyHv/e1olHqM+52H32TGu612v0 h0ghmFdAw9yUUwlU7hvdJTj4a9mdoB4psTA4L9RX/gpt4yDOrh/90ogepUMnYFsukDNR Zd6Y9N6g326AROTntT+kKt9LFStWSr+f6tT6vtmYxzSWdxELDCiISpCguimLALhFTk26 dJ1Ypy24KIiCW8JT8RxOyHAKpMIBIvnfOQ8q2tMHUb+a1v+TrWUd0Cldkjdv1B44ToBm M+TQ== X-Gm-Message-State: APjAAAVkms+ZiOCdv6Buw5IQpIyM/vQPpz7O80fkeINhY/U2B3v2Op4d Fw+yowT3kQPcFOFMKMwJvBfGcueZZv6WLA== X-Google-Smtp-Source: APXvYqzBZnQji8OBG2EMtpgCl/T/nh84H5uA+Y6VkGieSstfs7XbTrcHbi3MUg3tYmPmmk4Fb/BFNQ== X-Received: by 2002:adf:ed4b:: with SMTP id u11mr12050615wro.215.1574362259105; Thu, 21 Nov 2019 10:50:59 -0800 (PST) From: Wei Liu X-Google-Original-From: Wei Liu To: Xen Development List Date: Thu, 21 Nov 2019 18:50:48 +0000 Message-Id: <20191121185049.16666-8-liuwe@microsoft.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191121185049.16666-1-liuwe@microsoft.com> References: <20191121185049.16666-1-liuwe@microsoft.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v4 7/8] x86: be more verbose when running on a hypervisor 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) Also replace xen_guest with running_on_hypervisor boolean. Signed-off-by: Wei Liu --- Changes in v4: 1. Access ->name directly. 2. Drop Roger's review tag. --- xen/arch/x86/setup.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 19606d909b..123436b35a 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 =3D 0, bytes =3D 0; bool acpi_boot_table_init_done =3D false, relocated =3D false; int ret; + bool running_on_hypervisor; struct ns16550_defaults ns16550 =3D { .data_bits =3D 8, .parity =3D '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(); =20 - hypervisor_probe(); + running_on_hypervisor =3D !!hypervisor_probe(); =20 parse_video_info(); =20 @@ -788,6 +789,8 @@ void __init noreturn __start_xen(unsigned long mbi_p) printk("Command line: %s\n", cmdline); =20 printk("Xen image load base address: %#lx\n", xen_phys_start); + if ( running_on_hypervisor ) + printk("Running on %s\n", hypervisor_probe()->name); =20 #ifdef CONFIG_VIDEO printk("Video information:\n"); @@ -1569,7 +1572,7 @@ void __init noreturn __start_xen(unsigned long mbi_p) max_cpus =3D nr_cpu_ids; } =20 - if ( xen_guest ) + if ( running_on_hypervisor ) hypervisor_setup(); =20 /* Low mappings were only needed for some BIOS table parsing. */ --=20 2.20.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Tue Apr 23 15:46:43 2024 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=1574362328; cv=none; d=zoho.com; s=zohoarc; b=bi1p0yDxM2dw/jnZfwQZb9kPcbHCyDh2/cMtTCN7BCoxnH5ZOv1pRmjQfZ6hAotiwFP0o32rIVMXKSoKtqrEfBLnpt9xQUsiW4kqaZfXag6jJvDUoB5GDTjF9YnllkoiBDU8XK5/EFRVp6sQFW2j6vHK7HwWOsV5k28sQYcySKU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1574362328; 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=2ijGlo8wFolcsYAcGvHUawD3N+RF/PtIC8lu/tWMMhE=; b=DAlEqhMgDt1dQWDY3kkJ+4uhE2wczPVqX4YRVCSSmAP3nSrOk3V92pJy5oOWqrZ34qwexRjWzXognSXuRpvwC7pSmiAJ+CxxsULRHqcZ5/SZmaxHG6yuXe0UrFPC6hJ0d1F5T2PiL+dvJD2ajFX2J3ucqhQFSe/1e4X/rMM5mdE= 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 1574362328009404.7255732156091; Thu, 21 Nov 2019 10:52:08 -0800 (PST) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iXrYF-0007O9-95; Thu, 21 Nov 2019 18:51:35 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iXrYE-0007Nc-Ic for xen-devel@lists.xenproject.org; Thu, 21 Nov 2019 18:51:34 +0000 Received: from mail-wr1-x443.google.com (unknown [2a00:1450:4864:20::443]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id dc966b44-0c8f-11ea-adbe-bc764e2007e4; Thu, 21 Nov 2019 18:51:01 +0000 (UTC) Received: by mail-wr1-x443.google.com with SMTP id s5so5768534wrw.2 for ; Thu, 21 Nov 2019 10:51:01 -0800 (PST) Received: from debian.mshome.net (74.162.147.147.dyn.plus.net. [147.147.162.74]) by smtp.gmail.com with ESMTPSA id f24sm535776wmb.37.2019.11.21.10.50.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Nov 2019 10:50:59 -0800 (PST) X-Inumbo-ID: dc966b44-0c8f-11ea-adbe-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=8Y3wEFzVrOaDE1M8t+K3RG5EMlTBpIvMPtQ9f0XWpzE=; b=mgv2U2M5vAudGESEew+t5Hpz66OiCpH5eY2YEE65QpaWJf3Z2VnBPNz0Pc7jCzGqtJ iIZigNpf2PaeKxWuIEnRVpntFPvVBMYqAHjFlui7XiN+d6Kllho+VwZyvVtV+fjVracL f+8j7iKQDiOEEjoPxNX+0YhQtKZ2uCvhpelrvr035v8A4sCS5jTtclnsVaG/h3FniZaD 2jqBiR1CRepjHzL7wZZSUNn6NopeuJzqb3DwI2dpRiVLB/mSSjRz7/WwIH4w+rHbEEJ3 mU0TIhrN08txT6V1G898MZRVKikxUF/z6tCf4u4BkUYCG+IjNXsLlW56KA+3+OC8khD8 Olwg== 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=8Y3wEFzVrOaDE1M8t+K3RG5EMlTBpIvMPtQ9f0XWpzE=; b=ScQbU6WDY4jcRFmZ4BLy/gdgFEN6I12tswhVWtZBQV3AdDBtUmpchG0lTPcKqOOVxb XN+abQh1kwUlWUmhdkrMBucCELjh0PTkZ44LTPOuSJdHxQ2ngQMlLJWr3pSp+BY49S/V MkgoC8CQxorJrcqgYLTCXF1MKxwd7m1WrTtHl5Awtmn7ohUvU/JkPUvNuG+0/7FsBA7Z ckHFAVDc6SK4T7AKfGOb/HbADs8IXuXyC/GbT6jvwZn/qbXz8aplKurCoGLvrZGGDgQA rwe1c+nhBtT6z7/W+Ku5SmwjFi/MlIod2NUyBBgipv9C7dVqwG9COj4kiq7NMuQSlN/4 9CnQ== X-Gm-Message-State: APjAAAVpSNyhBHPp0Go/Y2FmXp2cNfldbPwyh/58a8RW/IGRqufdIzSg 5RfRqDJMGCKZKrUtD9wjO4snVu9qXOOLPw== X-Google-Smtp-Source: APXvYqxKquMkLF9FGNgpMrZx4pKWQDMoNlBDz04Yi7jWgfkP/vEw9VKhOjUiu2xe81y72e5r6i1Klw== X-Received: by 2002:adf:db8e:: with SMTP id u14mr3743435wri.274.1574362260037; Thu, 21 Nov 2019 10:51:00 -0800 (PST) From: Wei Liu X-Google-Original-From: Wei Liu To: Xen Development List Date: Thu, 21 Nov 2019 18:50:49 +0000 Message-Id: <20191121185049.16666-9-liuwe@microsoft.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191121185049.16666-1-liuwe@microsoft.com> References: <20191121185049.16666-1-liuwe@microsoft.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v4 8/8] x86: introduce CONFIG_HYPERV and detection code 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 use the same code structure as we did for Xen. As starters, detect Hyper-V in probe routine. More complex functionalities will be added later. Take the chance to fix XEN_GUEST in Kconfig. Signed-off-by: Wei Liu --- Changes in V4: 1. Add comment regarding order of probe functions. 2. Adapt to changes in previous patches. --- xen/arch/x86/Kconfig | 11 ++++-- xen/arch/x86/guest/Makefile | 1 + xen/arch/x86/guest/hyperv/Makefile | 1 + xen/arch/x86/guest/hyperv/hyperv.c | 54 ++++++++++++++++++++++++++++++ xen/arch/x86/guest/hypervisor.c | 8 +++++ xen/include/asm-x86/guest.h | 1 + xen/include/asm-x86/guest/hyperv.h | 43 ++++++++++++++++++++++++ 7 files changed, 117 insertions(+), 2 deletions(-) create mode 100644 xen/arch/x86/guest/hyperv/Makefile create mode 100644 xen/arch/x86/guest/hyperv/hyperv.c create mode 100644 xen/include/asm-x86/guest/hyperv.h diff --git a/xen/arch/x86/Kconfig b/xen/arch/x86/Kconfig index 867de857e8..0a02b6ee3f 100644 --- a/xen/arch/x86/Kconfig +++ b/xen/arch/x86/Kconfig @@ -164,10 +164,17 @@ endchoice config GUEST bool =20 +config HYPERV_GUEST + bool "Hyper-V Guest" + select GUEST + ---help--- + Support for Xen detecting when it is running under Hyper-V. + + If unsure, say N. + config XEN_GUEST - def_bool n + bool "Xen Guest" select GUEST - prompt "Xen Guest" ---help--- Support for Xen detecting when it is running under Xen. =20 diff --git a/xen/arch/x86/guest/Makefile b/xen/arch/x86/guest/Makefile index f63d64bbee..f164196772 100644 --- a/xen/arch/x86/guest/Makefile +++ b/xen/arch/x86/guest/Makefile @@ -1,3 +1,4 @@ obj-y +=3D hypervisor.o =20 +subdir-$(CONFIG_HYPERV_GUEST) +=3D hyperv subdir-$(CONFIG_XEN_GUEST) +=3D xen diff --git a/xen/arch/x86/guest/hyperv/Makefile b/xen/arch/x86/guest/hyperv= /Makefile new file mode 100644 index 0000000000..68170109a9 --- /dev/null +++ b/xen/arch/x86/guest/hyperv/Makefile @@ -0,0 +1 @@ +obj-y +=3D hyperv.o diff --git a/xen/arch/x86/guest/hyperv/hyperv.c b/xen/arch/x86/guest/hyperv= /hyperv.c new file mode 100644 index 0000000000..916e08ff89 --- /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 . + * + * Copyright (c) 2019 Microsoft. + */ +#include + +#include + +static const struct hypervisor_ops hyperv_ops =3D { + .name =3D "Hyper-V", +}; + +const struct hypervisor_ops * __init hyperv_probe(void) +{ + uint32_t eax, ebx, ecx, edx; + + cpuid(0x40000000, &eax, &ebx, &ecx, &edx); + if ( !((ebx =3D=3D 0x7263694d) && /* "Micr" */ + (ecx =3D=3D 0x666f736f) && /* "osof" */ + (edx =3D=3D 0x76482074)) ) /* "t Hv" */ + return NULL; + + cpuid(0x40000001, &eax, &ebx, &ecx, &edx); + if ( eax !=3D 0x31237648 ) /* Hv#1 */ + return NULL; + + return &hyperv_ops; +} + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/xen/arch/x86/guest/hypervisor.c b/xen/arch/x86/guest/hyperviso= r.c index a067cacecb..c293e185cc 100644 --- a/xen/arch/x86/guest/hypervisor.c +++ b/xen/arch/x86/guest/hypervisor.c @@ -39,6 +39,14 @@ const struct hypervisor_ops *hypervisor_probe(void) if ( hops ) goto out; =20 + /* + * Detection of Hyper-V must come after Xen to avoid false positive due + * to viridian support + */ + hops =3D hyperv_probe(); + if ( hops ) + goto out; + out: return hops; } diff --git a/xen/include/asm-x86/guest.h b/xen/include/asm-x86/guest.h index 8e167165ae..94448606d4 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/hyperv.h b/xen/include/asm-x86/guest= /hyperv.h new file mode 100644 index 0000000000..3f88b94c77 --- /dev/null +++ b/xen/include/asm-x86/guest/hyperv.h @@ -0,0 +1,43 @@ +/*************************************************************************= ***** + * asm-x86/guest/hyperv.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_GUEST_HYPERV_H__ +#define __X86_GUEST_HYPERV_H__ + +#ifdef CONFIG_HYPERV_GUEST + +#include + +const struct hypervisor_ops *hyperv_probe(void); + +#else + +static inline const struct hypervisor_ops *hyperv_probe(void) { return NUL= L; } + +#endif /* CONFIG_HYPERV_GUEST */ +#endif /* __X86_GUEST_HYPERV_H__ */ + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ --=20 2.20.1 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel