From patchwork Mon Sep 23 10:09:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Wei Liu X-Patchwork-Id: 11156549 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 25E8D112B for ; Mon, 23 Sep 2019 10:11:13 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EF85220820 for ; Mon, 23 Sep 2019 10:11:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="rfOY0YM/" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EF85220820 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=xen.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iCLHs-0006oO-Dx; Mon, 23 Sep 2019 10:09:44 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iCLHr-0006oG-9A for xen-devel@lists.xenproject.org; Mon, 23 Sep 2019 10:09:43 +0000 X-Inumbo-ID: 4006c716-ddea-11e9-b299-bc764e2007e4 Received: from mail-wm1-x342.google.com (unknown [2a00:1450:4864:20::342]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 4006c716-ddea-11e9-b299-bc764e2007e4; Mon, 23 Sep 2019 10:09:38 +0000 (UTC) Received: by mail-wm1-x342.google.com with SMTP id 3so8597401wmi.3 for ; Mon, 23 Sep 2019 03:09:38 -0700 (PDT) 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=WfEwbooFHv5S4uohbQtKqFZG0alfSTL0zc81uOqCx5Q=; b=rfOY0YM/GS8B4DZaHL04QXqwE9/Z8EQHCCqC8SIXPOn6TzOvqts5fPPXBjFZeii78B YchAW+yyDMpTIv+oF5XnuIJ0Qn0VPYV37MXY/SyShIQTOJWQEBW3BY7Q81zPnsl2XHiZ kc+8C8sfwN5Ical+rvSFXKCo7+83YA9lHlJvC70Op3lnf2i3uEkcRx2nKM+Hb0C6vETj YCgyTvUCWiqNdXxSSIBKHfqg1DK7GzSHxzIIz+buO4a+4pImvvpsSzmc1yJr/3rTmBKd pA6WC6W1yxNYzjCSKdKvSma1XL8Ud/ygSVssgYxybWZBz0rhTvbbgf7rVWOjvTIxgNCw JDkg== 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=WfEwbooFHv5S4uohbQtKqFZG0alfSTL0zc81uOqCx5Q=; b=Ha4TfcemyaFHqiQU/DLC2AWRcqDGpL/Wc5pMhuACtK83qS/QrAc7+oqYsYIhpVKFIO /GVYu90L/YznILrt1gil0hLA/3uWfdDv7fx8RMA2oQUG/gcff1ZUHfBaWmaYIIbS7Cmi X0YYhaV4bmivfNRXjg81to8FTFE8T/HBt38epF7gx/c5ZMA+3V2ulKOnmYonZUupI71m 27eUzRzh466Zl9PUQcnGBdiqgkkLRL79+zxhyoj6vrcX9U9BgNN5W/IvvBSWLQ72qe0c zRT4G41zJH13paz3cWW2YyE22gMy+yJXN8uhYHhnKjt1pdSWP6xAZKVj5Em6Chd0oYfs L/sA== X-Gm-Message-State: APjAAAXq/7nBFyXJkmIDb6WuV2EAxUAPMJJ3ZPg4umeL9v4TulBGH5oF k7kD6SyzWNRWAy0wxDgvsAc6X9Ii X-Google-Smtp-Source: APXvYqymy6baXzi0Y9kq559ouYA+w9Oj465awni9IyfMroJ2t1VNktR9c4NPWiaqmCi7JJpFOX3i+w== X-Received: by 2002:a05:600c:118a:: with SMTP id i10mr12986650wmf.80.1569233377350; Mon, 23 Sep 2019 03:09:37 -0700 (PDT) Received: from debian.mshome.net (207.148.159.143.dyn.plus.net. [143.159.148.207]) by smtp.gmail.com with ESMTPSA id s10sm18241662wmf.48.2019.09.23.03.09.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Sep 2019 03:09:36 -0700 (PDT) From: Wei Liu X-Google-Original-From: Wei Liu To: Xen Development List Date: Mon, 23 Sep 2019 11:09:24 +0100 Message-Id: <20190923100931.29670-2-liuwe@microsoft.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190923100931.29670-1-liuwe@microsoft.com> References: <20190923100931.29670-1-liuwe@microsoft.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH for-next RFC 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_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" 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é --- 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/{ => xen}/hypercall_page.S | 0 xen/arch/x86/guest/{ => xen}/pvh-boot.c | 0 xen/arch/x86/guest/{ => 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/{ => xen}/hypercall_page.S (100%) rename xen/arch/x86/guest/{ => xen}/pvh-boot.c (100%) rename xen/arch/x86/guest/{ => xen}/xen.c (100%) diff --git a/xen/arch/x86/Kconfig b/xen/arch/x86/Kconfig index 288dc6c042..584bdc1bb8 100644 --- a/xen/arch/x86/Kconfig +++ b/xen/arch/x86/Kconfig @@ -160,8 +160,12 @@ config XEN_ALIGN_2M endchoice +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 2443fd2cc5..99a12d0090 100644 --- a/xen/arch/x86/Makefile +++ b/xen/arch/x86/Makefile @@ -1,7 +1,7 @@ subdir-y += acpi subdir-y += cpu subdir-y += genapic -subdir-$(CONFIG_XEN_GUEST) += guest +subdir-$(CONFIG_GUEST) += guest subdir-$(CONFIG_HVM) += hvm subdir-y += mm subdir-$(CONFIG_XENOPROF) += 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 += hypercall_page.o -obj-y += xen.o - -obj-bin-$(CONFIG_PVH_GUEST) += pvh-boot.init.o +subdir-$(CONFIG_XEN_GUEST) += xen diff --git a/xen/arch/x86/guest/xen/Makefile b/xen/arch/x86/guest/xen/Makefile new file mode 100644 index 0000000000..26fb4b1007 --- /dev/null +++ b/xen/arch/x86/guest/xen/Makefile @@ -0,0 +1,4 @@ +obj-y += hypercall_page.o +obj-y += xen.o + +obj-bin-$(CONFIG_PVH_GUEST) += pvh-boot.init.o diff --git a/xen/arch/x86/guest/hypercall_page.S b/xen/arch/x86/guest/xen/hypercall_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-boot.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 From patchwork Mon Sep 23 10:09:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Wei Liu X-Patchwork-Id: 11156559 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 49DE7112B for ; Mon, 23 Sep 2019 10:11:41 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 25A6F20820 for ; Mon, 23 Sep 2019 10:11:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="i/xagpyo" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 25A6F20820 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=xen.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iCLHx-0006pA-N7; Mon, 23 Sep 2019 10:09:49 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iCLHw-0006p1-8W for xen-devel@lists.xenproject.org; Mon, 23 Sep 2019 10:09:48 +0000 X-Inumbo-ID: 4071e654-ddea-11e9-b76c-bc764e2007e4 Received: from mail-wm1-x342.google.com (unknown [2a00:1450:4864:20::342]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 4071e654-ddea-11e9-b76c-bc764e2007e4; Mon, 23 Sep 2019 10:09:39 +0000 (UTC) Received: by mail-wm1-x342.google.com with SMTP id r17so14614132wme.0 for ; Mon, 23 Sep 2019 03:09:38 -0700 (PDT) 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=kPofIqwbyjOoJizNjCH8bRsoi60N2OKNI61f/mmLNAk=; b=i/xagpyoe8g+/GqcncCG/OHrj2QLQl7AkCtRxVDSkIbDzLix9stO6YproSkO8EDeK3 LXL8AtwLG1H4O7EyV4qcDwcWhAI4ZiXrWpUapuCkJcPR5Yf7jt6F2zXGV9t4vIm/gHhV 5a32IBxNK1ftgWqXW2/4PbsNyfJJpLb5wBPxxcDm0xFyKIVnj8vBmAeCgn9G2KuIxi1o ZgXokMJJ/FnJV91J9flN7iw9ydNg4LRmBwYRLzql2uNU2tuFroY96XmQMFkDOx0q9dZp HeM3XJuEf7lcMvKxe7VhJyxI5vkcvX6v0DVbCNv3sCm+miktdHh0eDuB69r7LgGkaFso pdDQ== 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=kPofIqwbyjOoJizNjCH8bRsoi60N2OKNI61f/mmLNAk=; b=cSw3E3aCWeMi4d63T1y1pRMiTC68kanWnpmt6ghq1NtHLSMhIWW/jDRDaLcV1mZyAR +c5KJOVT2gKnP7n0g4EO8ELHg1d5qwRYP6sGvAD4lb7dyZmjYVvVZx0M5gtBZQu5F90W wvUYPsoZXab5OPk4YDelMSG/h5eonXpPpVP1J8FuEzVUxau9mQscIIFQvrhNERzicfuC aRL5qOJH/VnsIAm1RLMDHIeGbMVPIh/zBtVdxFSCWZIkh3vXipZhWM3lGUA2qNxBpUpT OpXeCSFH8FBPd6uLqrhmV43M/vBj2ZHUJNEDfQk5FBCQUUsVtU9Og03+fFQfbKibENIZ 0CIQ== X-Gm-Message-State: APjAAAXc6lo5Nbr0p2QVV78yTf2T6/Giw/YW2vxVDQkMr/mPSdbPDotI MvDdvnRaAejqZEQUl70PxVKOmI/w X-Google-Smtp-Source: APXvYqyASZuoeD0QtJNj2pdjbXLZAVpehovFJByeA0LLms/QxzTW7pNQKgCBxKueCw/iExf4ZO1WQw== X-Received: by 2002:a05:600c:1089:: with SMTP id e9mr13525949wmd.176.1569233378102; Mon, 23 Sep 2019 03:09:38 -0700 (PDT) Received: from debian.mshome.net (207.148.159.143.dyn.plus.net. [143.159.148.207]) by smtp.gmail.com with ESMTPSA id s10sm18241662wmf.48.2019.09.23.03.09.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Sep 2019 03:09:37 -0700 (PDT) From: Wei Liu X-Google-Original-From: Wei Liu To: Xen Development List Date: Mon, 23 Sep 2019 11:09:25 +0100 Message-Id: <20190923100931.29670-3-liuwe@microsoft.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190923100931.29670-1-liuwe@microsoft.com> References: <20190923100931.29670-1-liuwe@microsoft.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH for-next RFC 2/8] x86: include asm_defns.h directly 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_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" ASM_CALL_CONSTRAINT is defined there. No functional change. Signed-off-by: Wei Liu Reviewed-by: Roger Pau Monné --- xen/include/asm-x86/guest/hypercall.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/xen/include/asm-x86/guest/hypercall.h b/xen/include/asm-x86/guest/hypercall.h index d548816b30..c9deca6ffc 100644 --- a/xen/include/asm-x86/guest/hypercall.h +++ b/xen/include/asm-x86/guest/hypercall.h @@ -23,6 +23,8 @@ #include +#include + #include #include #include From patchwork Mon Sep 23 10:09:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Wei Liu X-Patchwork-Id: 11156551 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2971017D4 for ; Mon, 23 Sep 2019 10:11:18 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0558420820 for ; Mon, 23 Sep 2019 10:11:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="XY2tDeIp" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0558420820 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=xen.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iCLI3-0006rK-5L; Mon, 23 Sep 2019 10:09:55 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iCLI1-0006qr-9f for xen-devel@lists.xenproject.org; Mon, 23 Sep 2019 10:09:53 +0000 X-Inumbo-ID: 40facc62-ddea-11e9-a337-bc764e2007e4 Received: from mail-wm1-x341.google.com (unknown [2a00:1450:4864:20::341]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 40facc62-ddea-11e9-a337-bc764e2007e4; Mon, 23 Sep 2019 10:09:39 +0000 (UTC) Received: by mail-wm1-x341.google.com with SMTP id y21so8621697wmi.0 for ; Mon, 23 Sep 2019 03:09:39 -0700 (PDT) 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=qOnvgxTYDq1RQTeNxzoSrcZSvYUJJofuL+Y7imyRsBI=; b=XY2tDeIpfAvkFQx8RaGzo+iVyMmjmvXl9fW/7EsS2TKQEe5+W4FJvsK5uFqCU2Vh4p fnm35QH83HqiHJyc49LzyuBVW66t8HFGUtQzoZfxtcKDrnldKFqrwL9LBXsrLyolCTcx excyCe720WLnb+F8jTQ+cej7gIZtpyGHbjECnV1PpHXlZUOdc2XbRYZ8gzumiHOqTUu1 BsjBGj1u+RHBe4+w2YCmNkjPlJf8aBN8HNtKI5EDyol2DiYqWNjYzOX9P0dSO/Js+2lW Bj1FDc8Hk3Nr953IPKKnMEkKTDZDNpVBDDSGUYeMVSUoSUr6T3HpJeiGQ/csN3vI/jV/ YkVA== 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=qOnvgxTYDq1RQTeNxzoSrcZSvYUJJofuL+Y7imyRsBI=; b=Lt4sX7bZPQfOKu+Ha3fkfaRmbHGOQr/IH+2UqoMh6wwcHEayH7kWdsAGQC51Yo4qQk MlUfJrpBFRl4FHiWNICq4pLRpnRLBXR1W5CtTN5KOXseRmw8ieUmxqqvqDG1kBAh7cJ5 nkT8uiE4FB4pY1RniG8py0WfJIY/vc6E3rm32tpbAUk/x9E4G5MLTaYfRi9uczfA4jP4 kpYfp1OLgCj63FjYHu5v4WiFtwQFDgWS97Pdr8HuRtTFaw+HtboLzXy57JxHkUIb3fWF 5wStrUV3Iihh1w2HaZnGbUvTgSkJRnkfkGRLALGGxDTS7nGcAFtAk0j0VgO6G1pFt5GX nf+Q== X-Gm-Message-State: APjAAAX92WK9iaAE8tGmrcpSx0rhcJuub45/o6zVqPMkioK1ignjZ/cL Evq9NmAS6zrOUSN0xja2ST5SA0kq X-Google-Smtp-Source: APXvYqxP5XgaxhG1fhSiuV5+Hw+0TvnZxKbGApNAIrK1/bqxkw2Qt/sRHIOZBBUqNWAJj7J2CdQHsQ== X-Received: by 2002:a1c:3904:: with SMTP id g4mr13797846wma.116.1569233378852; Mon, 23 Sep 2019 03:09:38 -0700 (PDT) Received: from debian.mshome.net (207.148.159.143.dyn.plus.net. [143.159.148.207]) by smtp.gmail.com with ESMTPSA id s10sm18241662wmf.48.2019.09.23.03.09.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Sep 2019 03:09:38 -0700 (PDT) From: Wei Liu X-Google-Original-From: Wei Liu To: Xen Development List Date: Mon, 23 Sep 2019 11:09:26 +0100 Message-Id: <20190923100931.29670-4-liuwe@microsoft.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190923100931.29670-1-liuwe@microsoft.com> References: <20190923100931.29670-1-liuwe@microsoft.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH for-next RFC 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_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" The only user is Xen specific code in PV shim. We can therefore export the variable directly. Signed-off-by: Wei Liu Reviewed-by: Roger Pau Monné --- 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 7b7a5badab..78fc603996 100644 --- a/xen/arch/x86/guest/xen/xen.c +++ b/xen/arch/x86/guest/xen/xen.c @@ -37,7 +37,7 @@ bool __read_mostly xen_guest; -static __read_mostly uint32_t xen_cpuid_base; +__read_mostly uint32_t xen_cpuid_base; extern char hypercall_page[]; static struct rangeset *mem; @@ -301,11 +301,6 @@ int hypervisor_free_unused_page(mfn_t mfn) return rangeset_remove_range(mem, mfn_x(mfn), mfn_x(mfn)); } -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 324ca27f93..1b174c24df 100644 --- a/xen/arch/x86/pv/shim.c +++ b/xen/arch/x86/pv/shim.c @@ -992,7 +992,7 @@ domid_t get_initial_domain_id(void) if ( !pv_shim ) return 0; - cpuid(hypervisor_cpuid_base() + 4, &eax, &ebx, &ecx, &edx); + cpuid(xen_cpuid_base + 4, &eax, &ebx, &ecx, &edx); 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/xen.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 @@ extern bool xen_guest; extern bool pv_console; +extern uint32_t xen_cpuid_base; 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); DECLARE_PER_CPU(unsigned int, vcpu_id); From patchwork Mon Sep 23 10:09:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Liu X-Patchwork-Id: 11156563 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2452317D4 for ; Mon, 23 Sep 2019 10:11:42 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F38AD20820 for ; Mon, 23 Sep 2019 10:11:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Ep23HRbz" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F38AD20820 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=xen.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iCLI7-0006sx-Gy; Mon, 23 Sep 2019 10:09:59 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iCLI6-0006sY-9i for xen-devel@lists.xenproject.org; Mon, 23 Sep 2019 10:09:58 +0000 X-Inumbo-ID: 417988b8-ddea-11e9-b299-bc764e2007e4 Received: from mail-wm1-x342.google.com (unknown [2a00:1450:4864:20::342]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 417988b8-ddea-11e9-b299-bc764e2007e4; Mon, 23 Sep 2019 10:09:40 +0000 (UTC) Received: by mail-wm1-x342.google.com with SMTP id m18so8619608wmc.1 for ; Mon, 23 Sep 2019 03:09:40 -0700 (PDT) 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=UqfVM3xb9A0eu4hPr4BRnP3HYQakt7P75+x7Ufcd7qY=; b=Ep23HRbzXiZPbX58oxtkUbGl/KV0RWeBVEi+qndp39CTAXj1lvBfYSMNunVqxv0KEm PCz2by9LNNBZAv//itRcF6UZ/9k0vwOCMO7YyfCj88bQZie186pXZaju6TFx2guW4yak vdX3SXi3jS+w7PWOxVAEilBCMWGRiqYQH29oedGmRgzdgrJOaVscmo8L8I2G53AH5fPz U8OkzV0YmlDfgcAymkaomlA0MWzj3uatTrIqQJaG3TONHdu3N6iqcAZLX4EFCaewDkbA uTWB3Euto6x2oG3W67m/6d2sfYkWv3IjYiM78wxvDDB84t1/WermbPf9D8uGxTT7RI+l 0bgA== 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=UqfVM3xb9A0eu4hPr4BRnP3HYQakt7P75+x7Ufcd7qY=; b=UUicReG+ysM4dhmCNNHNAwOPweDEqzV671mI7X7BJ45JJgNy115rQd4fbhgd5x1JBJ 8rYNb1vKunYvAhbiDKT2FkEywATazlbUB2+b1q7qdVQJiwedt5a6pcJ6yiWAiPccae82 VsRg5lK2yWibcQ/JADrAllkaWhnH24AReu6PetwPDjs7H6JYGo9s5wjg8X4B/iGpSbwk KET0E733D0bH9iSQXALmuTpOWcg1FHuC2+hWvifZNK69J1KTC5hNTclkqx3JXRv0j7Pc nkATKdrH8uzTyHBPg6gUWDpZrBzrvSQRWvEqse4V0sASZxvQeIUr7+hGB1iEu1gXa7k1 RNEg== X-Gm-Message-State: APjAAAWtcs5UJFaL9a8B0csCI34VPIOXy/snbIAchOfWzjPcTkiY7JsB nrMncRpkMywAh7GektfdpxE9CLZJ X-Google-Smtp-Source: APXvYqwPDn7qWlE5iQ2Ta9VT5C8jG0MlQ/uyJZ0v21SIYsfPL6BHHneQyzJFPwI/nvgyOway1JNbgQ== X-Received: by 2002:a05:600c:c2:: with SMTP id u2mr12218904wmm.37.1569233379730; Mon, 23 Sep 2019 03:09:39 -0700 (PDT) Received: from debian.mshome.net (207.148.159.143.dyn.plus.net. [143.159.148.207]) by smtp.gmail.com with ESMTPSA id s10sm18241662wmf.48.2019.09.23.03.09.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Sep 2019 03:09:39 -0700 (PDT) From: Wei Liu X-Google-Original-From: Wei Liu To: Xen Development List Date: Mon, 23 Sep 2019 11:09:27 +0100 Message-Id: <20190923100931.29670-5-liuwe@microsoft.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190923100931.29670-1-liuwe@microsoft.com> References: <20190923100931.29670-1-liuwe@microsoft.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH for-next RFC 4/8] x86: factor out xen variants for hypervisor setup 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_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" We will add Hyper-V specific implementations in the future. No functional change. Signed-off-by: Wei Liu --- xen/arch/x86/guest/xen/xen.c | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/xen/arch/x86/guest/xen/xen.c b/xen/arch/x86/guest/xen/xen.c index 78fc603996..f93c8fbd1c 100644 --- a/xen/arch/x86/guest/xen/xen.c +++ b/xen/arch/x86/guest/xen/xen.c @@ -67,7 +67,7 @@ static void __init find_xen_leaves(void) } } -void __init probe_hypervisor(void) +static void __init probe_xen(void) { if ( xen_guest ) return; @@ -87,6 +87,11 @@ void __init probe_hypervisor(void) xen_guest = true; } +void __init probe_hypervisor(void) +{ + probe_xen(); +} + static void map_shared_info(void) { mfn_t mfn; @@ -249,10 +254,8 @@ static void init_evtchn(void) } } -void __init hypervisor_setup(void) +static void __init xen_setup(void) { - init_memmap(); - map_shared_info(); set_vcpu_id(); @@ -277,13 +280,25 @@ void __init hypervisor_setup(void) init_evtchn(); } -void hypervisor_ap_setup(void) +void __init hypervisor_setup(void) +{ + init_memmap(); + + xen_setup(); +} + +static void xen_ap_setup(void) { set_vcpu_id(); map_vcpuinfo(); init_evtchn(); } +void hypervisor_ap_setup(void) +{ + xen_ap_setup(); +} + int hypervisor_alloc_unused_page(mfn_t *mfn) { unsigned long m; @@ -307,7 +322,7 @@ static void ap_resume(void *unused) init_evtchn(); } -void hypervisor_resume(void) +static void xen_resume(void) { /* Reset shared info page. */ map_shared_info(); @@ -330,6 +345,11 @@ void hypervisor_resume(void) pv_console_init(); } +void hypervisor_resume(void) +{ + xen_resume(); +} + /* * Local variables: * mode: C From patchwork Mon Sep 23 10:09:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Liu X-Patchwork-Id: 11156553 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A9E8D17D4 for ; Mon, 23 Sep 2019 10:11:20 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7A44120820 for ; Mon, 23 Sep 2019 10:11:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Ix3DCsHF" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7A44120820 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=xen.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iCLIC-000791-SC; Mon, 23 Sep 2019 10:10:04 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iCLIB-00071D-9F for xen-devel@lists.xenproject.org; Mon, 23 Sep 2019 10:10:03 +0000 X-Inumbo-ID: 42083da6-ddea-11e9-b76c-bc764e2007e4 Received: from mail-wm1-x341.google.com (unknown [2a00:1450:4864:20::341]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 42083da6-ddea-11e9-b76c-bc764e2007e4; Mon, 23 Sep 2019 10:09:41 +0000 (UTC) Received: by mail-wm1-x341.google.com with SMTP id a6so9172509wma.5 for ; Mon, 23 Sep 2019 03:09:41 -0700 (PDT) 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=faSPq0/FgKeXO1cnxCD0/aZRNuNgVtyb3U2iGwfHW2c=; b=Ix3DCsHFPzP3J3dL6O2hVzBd3LE9Un/nuiFBQcrq1KWyUftPQGzwsbLXnXk/5RAdbp rdEhtMpSeSdluGv1LAnaOzhr7lVx4ipZuODr5bXFRQtXWbfeM7SQBYGMGaN3JOK+AEIE iXD9VlYk0AfyBSGnjo/hUavTwnxilY5NsODhfTA2Dc7H7kJOxXVp0WSczR5p1s6xS4IN RuaV2/Mh44LqeSWJGyStcUtjq392q5QaSCnuvCqfsizgyMP6eoibIEya9lMa/b/w4ezf 3aTPETLb9tcIVqH1TnbP1tRgLcc1l1u5pwPZ9VOvAEr7geJr4uP9fRVcHFSjp9Z7vszq VWaw== 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=faSPq0/FgKeXO1cnxCD0/aZRNuNgVtyb3U2iGwfHW2c=; b=QJnitIT5TtuhCcFrJvzDxVc+F5VdO2ezLw1BfOlrYYckfrU32sa819IYFbtUEdGfrh D4sptlAtMXbFg2EXjTHVpHJiF66UWM3qH9mV5x083XMzRx062nrfPhwNe/6X66tFVMUP EjpE1cXgGoFp7qJn4/R8F1DxcnAHMEnXDG1LkMLu9kZg6v2c7lJnKWTiDFvSecplVGQh HOtiGqF3mX/4Nhmu/WyV4ov+QO+dzR/uUfuWEgdB24Ly1QrJpDzwpBDY/f3W0faHq4vL fiAWQxkIe6ac6SM8/+ZmHk8qlyMBXwUvLioYxD+uzcb5nRdDenKOQQDa/pvbYOiezaIM f8Nw== X-Gm-Message-State: APjAAAVgV0Roa8P7Wpf7IsCg530GI0P++pNEtJ7kv8XzoDblMD4mlSix f+jZNGIBcXmtmS5unSuEZDz6Gl87 X-Google-Smtp-Source: APXvYqwjh0Q6C3SRY+SzsVrgkwn4+OS9/PS6Ifq2LiKwvhdg3lABmd4ip5XFWOoA1xChqGi44NWjWg== X-Received: by 2002:a7b:cd83:: with SMTP id y3mr13582130wmj.165.1569233380548; Mon, 23 Sep 2019 03:09:40 -0700 (PDT) Received: from debian.mshome.net (207.148.159.143.dyn.plus.net. [143.159.148.207]) by smtp.gmail.com with ESMTPSA id s10sm18241662wmf.48.2019.09.23.03.09.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Sep 2019 03:09:40 -0700 (PDT) From: Wei Liu X-Google-Original-From: Wei Liu To: Xen Development List Date: Mon, 23 Sep 2019 11:09:28 +0100 Message-Id: <20190923100931.29670-6-liuwe@microsoft.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190923100931.29670-1-liuwe@microsoft.com> References: <20190923100931.29670-1-liuwe@microsoft.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH for-next RFC 5/8] x86: factor out hypervisor agnostic 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_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" The only implementation there is Xen. No functional change. Signed-off-by: Wei Liu --- xen/arch/x86/guest/Makefile | 2 + xen/arch/x86/guest/hypervisor.c | 112 +++++++++++++++++++++++++ xen/arch/x86/guest/xen/xen.c | 81 +----------------- xen/include/asm-x86/guest.h | 1 + xen/include/asm-x86/guest/hypervisor.h | 58 +++++++++++++ xen/include/asm-x86/guest/xen.h | 21 ++--- 6 files changed, 182 insertions(+), 93 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 += hypervisor.o + subdir-$(CONFIG_XEN_GUEST) += xen diff --git a/xen/arch/x86/guest/hypervisor.c b/xen/arch/x86/guest/hypervisor.c new file mode 100644 index 0000000000..b0a724bf13 --- /dev/null +++ b/xen/arch/x86/guest/hypervisor.c @@ -0,0 +1,112 @@ +/****************************************************************************** + * 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) 2017 Citrix Systems Ltd. + */ + +#include +#include +#include + +#include +#include + +static struct rangeset *mem; + +void __init probe_hypervisor(void) +{ + /* Too early to use cpu_has_hypervisor */ + if ( !(cpuid_ecx(1) & cpufeat_mask(X86_FEATURE_HYPERVISOR)) ) + return; + + probe_xen(); +} + +static void __init init_memmap(void) +{ + unsigned int i; + + mem = rangeset_new(NULL, "host memory map", 0); + if ( !mem ) + panic("failed to allocate PFN usage rangeset\n"); + + /* + * Mark up to the last memory page (or 4GiB) as RAM. This is done because + * Xen doesn't know the position of possible MMIO holes, so at least try to + * avoid the know MMIO hole below 4GiB. Note that this is subject to future + * discussion and improvements. + */ + if ( rangeset_add_range(mem, 0, max_t(unsigned long, max_page - 1, + PFN_DOWN(GB(4) - 1))) ) + panic("unable to add RAM to in-use PFN rangeset\n"); + + for ( i = 0; i < e820.nr_map; i++ ) + { + struct e820entry *e = &e820.map[i]; + + if ( rangeset_add_range(mem, PFN_DOWN(e->addr), + PFN_UP(e->addr + e->size - 1)) ) + panic("unable to add range [%#lx, %#lx] to in-use PFN rangeset\n", + PFN_DOWN(e->addr), PFN_UP(e->addr + e->size - 1)); + } +} + +void __init hypervisor_setup(void) +{ + init_memmap(); + + xen_setup(); +} + +void hypervisor_ap_setup(void) +{ + xen_ap_setup(); +} + +int hypervisor_alloc_unused_page(mfn_t *mfn) +{ + unsigned long m; + int rc; + + rc = rangeset_claim_range(mem, 1, &m); + if ( !rc ) + *mfn = _mfn(m); + + return rc; +} + +int hypervisor_free_unused_page(mfn_t mfn) +{ + return rangeset_remove_range(mem, mfn_x(mfn), mfn_x(mfn)); +} + +void hypervisor_resume(void) +{ + xen_resume(); +} + +/* + * 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/xen/xen.c b/xen/arch/x86/guest/xen/xen.c index f93c8fbd1c..a730e6ad1b 100644 --- a/xen/arch/x86/guest/xen/xen.c +++ b/xen/arch/x86/guest/xen/xen.c @@ -39,7 +39,6 @@ bool __read_mostly xen_guest; __read_mostly uint32_t xen_cpuid_base; extern char hypercall_page[]; -static struct rangeset *mem; DEFINE_PER_CPU(unsigned int, vcpu_id); @@ -67,15 +66,11 @@ static void __init find_xen_leaves(void) } } -static void __init probe_xen(void) +void __init probe_xen(void) { if ( xen_guest ) return; - /* Too early to use cpu_has_hypervisor */ - if ( !(cpuid_ecx(1) & cpufeat_mask(X86_FEATURE_HYPERVISOR)) ) - return; - find_xen_leaves(); if ( !xen_cpuid_base ) @@ -87,11 +82,6 @@ static void __init probe_xen(void) xen_guest = true; } -void __init probe_hypervisor(void) -{ - probe_xen(); -} - static void map_shared_info(void) { mfn_t mfn; @@ -166,35 +156,6 @@ static void set_vcpu_id(void) this_cpu(vcpu_id) = smp_processor_id(); } -static void __init init_memmap(void) -{ - unsigned int i; - - mem = rangeset_new(NULL, "host memory map", 0); - if ( !mem ) - panic("failed to allocate PFN usage rangeset\n"); - - /* - * Mark up to the last memory page (or 4GiB) as RAM. This is done because - * Xen doesn't know the position of possible MMIO holes, so at least try to - * avoid the know MMIO hole below 4GiB. Note that this is subject to future - * discussion and improvements. - */ - if ( rangeset_add_range(mem, 0, max_t(unsigned long, max_page - 1, - PFN_DOWN(GB(4) - 1))) ) - panic("unable to add RAM to in-use PFN rangeset\n"); - - for ( i = 0; i < e820.nr_map; i++ ) - { - struct e820entry *e = &e820.map[i]; - - if ( rangeset_add_range(mem, PFN_DOWN(e->addr), - PFN_UP(e->addr + e->size - 1)) ) - panic("unable to add range [%#lx, %#lx] to in-use PFN rangeset\n", - PFN_DOWN(e->addr), PFN_UP(e->addr + e->size - 1)); - } -} - static void xen_evtchn_upcall(struct cpu_user_regs *regs) { struct vcpu_info *vcpu_info = this_cpu(vcpu_info); @@ -254,7 +215,7 @@ static void init_evtchn(void) } } -static void __init xen_setup(void) +void __init xen_setup(void) { map_shared_info(); @@ -280,49 +241,20 @@ static void __init xen_setup(void) init_evtchn(); } -void __init hypervisor_setup(void) -{ - init_memmap(); - - xen_setup(); -} - -static void xen_ap_setup(void) +void xen_ap_setup(void) { set_vcpu_id(); map_vcpuinfo(); init_evtchn(); } -void hypervisor_ap_setup(void) -{ - xen_ap_setup(); -} - -int hypervisor_alloc_unused_page(mfn_t *mfn) -{ - unsigned long m; - int rc; - - rc = rangeset_claim_range(mem, 1, &m); - if ( !rc ) - *mfn = _mfn(m); - - return rc; -} - -int hypervisor_free_unused_page(mfn_t mfn) -{ - return rangeset_remove_range(mem, mfn_x(mfn), mfn_x(mfn)); -} - static void ap_resume(void *unused) { map_vcpuinfo(); init_evtchn(); } -static void xen_resume(void) +void xen_resume(void) { /* Reset shared info page. */ map_shared_info(); @@ -345,11 +277,6 @@ static void xen_resume(void) pv_console_init(); } -void hypervisor_resume(void) -{ - xen_resume(); -} - /* * Local variables: * mode: C 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__ #include +#include #include #include #include diff --git a/xen/include/asm-x86/guest/hypervisor.h b/xen/include/asm-x86/guest/hypervisor.h new file mode 100644 index 0000000000..135ad36f72 --- /dev/null +++ b/xen/include/asm-x86/guest/hypervisor.h @@ -0,0 +1,58 @@ +/****************************************************************************** + * 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 . + */ + +#ifndef __X86_GUEST_HYPERVISOR_H__ +#define __X86_GUEST_HYPERVISOR_H__ + +#ifdef CONFIG_GUEST + +#include + +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); + +#else + +#include + +static inline void probe_hypervisor(void) {} + +static inline void hypervisor_setup(void) +{ + ASSERT_UNREACHABLE(); +} +static inline void hypervisor_ap_setup(void) +{ + ASSERT_UNREACHABLE(); +} + +#endif /* CONFIG_GUEST */ +#endif /* __X86_GUEST_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/xen.h index b015ed1883..d031f1f70d 100644 --- a/xen/include/asm-x86/guest/xen.h +++ b/xen/include/asm-x86/guest/xen.h @@ -32,12 +32,10 @@ extern bool xen_guest; extern bool pv_console; extern uint32_t xen_cpuid_base; -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); +void probe_xen(void); +void xen_setup(void); +void xen_ap_setup(void); +void xen_resume(void); DECLARE_PER_CPU(unsigned int, vcpu_id); DECLARE_PER_CPU(struct vcpu_info *, vcpu_info); @@ -47,16 +45,7 @@ DECLARE_PER_CPU(struct vcpu_info *, vcpu_info); #define xen_guest 0 #define pv_console 0 -static inline void probe_hypervisor(void) {} - -static inline void hypervisor_setup(void) -{ - ASSERT_UNREACHABLE(); -} -static inline void hypervisor_ap_setup(void) -{ - ASSERT_UNREACHABLE(); -} +static inline void probe_xen(void) {} #endif /* CONFIG_XEN_GUEST */ #endif /* __X86_GUEST_XEN_H__ */ From patchwork Mon Sep 23 10:09:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Liu X-Patchwork-Id: 11156565 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7684717D4 for ; Mon, 23 Sep 2019 10:11:46 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5229920865 for ; Mon, 23 Sep 2019 10:11:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="PGil4XhY" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5229920865 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=xen.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iCLII-0007Wb-5T; Mon, 23 Sep 2019 10:10: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 1iCLIG-0007Tw-8z for xen-devel@lists.xenproject.org; Mon, 23 Sep 2019 10:10:08 +0000 X-Inumbo-ID: 4264c094-ddea-11e9-b299-bc764e2007e4 Received: from mail-wm1-x344.google.com (unknown [2a00:1450:4864:20::344]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 4264c094-ddea-11e9-b299-bc764e2007e4; Mon, 23 Sep 2019 10:09:42 +0000 (UTC) Received: by mail-wm1-x344.google.com with SMTP id m18so8619705wmc.1 for ; Mon, 23 Sep 2019 03:09:42 -0700 (PDT) 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=J0gWUg2h7tpdgfhePN1rbGU9ftmJv074Q5+IRkBqTX8=; b=PGil4XhYR6v62HYFcwiaSCYPWEF6MEg6hCwXjZuKaP4Aj7i5WKq/QH3zUtclD5scVt sESn8KrxnsfFTdchYW5vLvkzkaxVL2FBxZUCLfStN1jAW8LSDfo9R5oY0tylhwGpILiL U7oIqNWN5XQkozkg8kEeqQwxPBgx3doqx0t5pPjkwR2DSkT+PbPjZ3BxnrH0JcietLgQ GANPJpCPusX5YsA4qIJ2sEZxMLar/UUmLClL8J9c01F5z7xTpwULjPKK9mNX6A5KuDYW j0uCizKYM7w8YoURYr3pTyJzBJZMbT75DM0DcLa3lQBzOWYO53ehnwVfccMUKOB1GxR4 YaCg== 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=J0gWUg2h7tpdgfhePN1rbGU9ftmJv074Q5+IRkBqTX8=; b=Z1zcjDSvz9rd7HYrEg7ceVLffOPXiVZAg/cJmiFB4xMljCMlYlDxMynrhylZAp6/BE uXMQh90FI2Sk2/6VLW/ZjaORxaFmDTEeGVqEGz+WJHH75QMLFhNsGZiW3gfmjqtEFp7m qs2FAqpabsrGc0dUObh1PPs5juHV1zVD9UIiWe3jOiS/rBgnCSGdZ+06QI6PsYFMwf3X tbBte0v+3/rDXGepBugQtbuTBsgOYVnyJKyA44nFyLEn+WTl3fgXqtCHenGLXKtIZRfd SCaP+aZ7PDZixT5M5/X+wun6aIb558y5OrlxZb9ZHI5rU1cwc4ErQOrQLu0qxjeGFf/F UKCA== X-Gm-Message-State: APjAAAW8hTGuzeY6dshjwhOKtLzkyfFWxkwiT8uyXwE/pt2m5CB4iQkh p1jfs+01w+YfOhEOwAEl0nd0Tz9k X-Google-Smtp-Source: APXvYqx7BqyC5ozDISUKqL4kgTWqLV6+d4HNGBkzXibQ1XS4BtpTE5Yi//FfuOXbkSgclyjdgBGuFA== X-Received: by 2002:a7b:c757:: with SMTP id w23mr12824379wmk.31.1569233381352; Mon, 23 Sep 2019 03:09:41 -0700 (PDT) Received: from debian.mshome.net (207.148.159.143.dyn.plus.net. [143.159.148.207]) by smtp.gmail.com with ESMTPSA id s10sm18241662wmf.48.2019.09.23.03.09.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Sep 2019 03:09:40 -0700 (PDT) From: Wei Liu X-Google-Original-From: Wei Liu To: Xen Development List Date: Mon, 23 Sep 2019 11:09:29 +0100 Message-Id: <20190923100931.29670-7-liuwe@microsoft.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190923100931.29670-1-liuwe@microsoft.com> References: <20190923100931.29670-1-liuwe@microsoft.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH for-next RFC 6/8] x86: make probe_xen return boolean value 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_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" We need indication whether it has succeeded or not. Signed-off-by: Wei Liu --- xen/arch/x86/guest/hypervisor.c | 5 ++++- xen/arch/x86/guest/xen/xen.c | 7 ++++--- xen/include/asm-x86/guest/xen.h | 4 ++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/xen/arch/x86/guest/hypervisor.c b/xen/arch/x86/guest/hypervisor.c index b0a724bf13..fb572b0402 100644 --- a/xen/arch/x86/guest/hypervisor.c +++ b/xen/arch/x86/guest/hypervisor.c @@ -34,7 +34,10 @@ void __init probe_hypervisor(void) if ( !(cpuid_ecx(1) & cpufeat_mask(X86_FEATURE_HYPERVISOR)) ) return; - probe_xen(); + if ( probe_xen() ) + return; + + /* Hyper-V probing to follow. */ } static void __init init_memmap(void) diff --git a/xen/arch/x86/guest/xen/xen.c b/xen/arch/x86/guest/xen/xen.c index a730e6ad1b..8390b045f0 100644 --- a/xen/arch/x86/guest/xen/xen.c +++ b/xen/arch/x86/guest/xen/xen.c @@ -66,20 +66,21 @@ static void __init find_xen_leaves(void) } } -void __init probe_xen(void) +bool __init probe_xen(void) { if ( xen_guest ) - return; + return true; find_xen_leaves(); if ( !xen_cpuid_base ) - return; + return false; /* Fill the hypercall page. */ wrmsrl(cpuid_ebx(xen_cpuid_base + 2), __pa(hypercall_page)); xen_guest = true; + return true; } static void map_shared_info(void) diff --git a/xen/include/asm-x86/guest/xen.h b/xen/include/asm-x86/guest/xen.h index d031f1f70d..7eda3d4956 100644 --- a/xen/include/asm-x86/guest/xen.h +++ b/xen/include/asm-x86/guest/xen.h @@ -32,7 +32,7 @@ extern bool xen_guest; extern bool pv_console; extern uint32_t xen_cpuid_base; -void probe_xen(void); +bool probe_xen(void); void xen_setup(void); void xen_ap_setup(void); void xen_resume(void); @@ -45,7 +45,7 @@ DECLARE_PER_CPU(struct vcpu_info *, vcpu_info); #define xen_guest 0 #define pv_console 0 -static inline void probe_xen(void) {} +static inline bool probe_xen(void) { return false; } #endif /* CONFIG_XEN_GUEST */ #endif /* __X86_GUEST_XEN_H__ */ From patchwork Mon Sep 23 10:09:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Liu X-Patchwork-Id: 11156557 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1BA6717D4 for ; Mon, 23 Sep 2019 10:11:31 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EB32720820 for ; Mon, 23 Sep 2019 10:11:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="CzQiMu1j" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EB32720820 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=xen.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iCLIM-0007Zm-Ly; Mon, 23 Sep 2019 10:10:14 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iCLIL-0007ZH-9y for xen-devel@lists.xenproject.org; Mon, 23 Sep 2019 10:10:13 +0000 X-Inumbo-ID: 42ff5546-ddea-11e9-b76c-bc764e2007e4 Received: from mail-wm1-x343.google.com (unknown [2a00:1450:4864:20::343]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 42ff5546-ddea-11e9-b76c-bc764e2007e4; Mon, 23 Sep 2019 10:09:43 +0000 (UTC) Received: by mail-wm1-x343.google.com with SMTP id f22so1465785wmc.2 for ; Mon, 23 Sep 2019 03:09:43 -0700 (PDT) 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=A9Koh0GsgVCT4pN4yJPa3MEazXKb1HbGcXbrkIuJu84=; b=CzQiMu1j5ykcWRa7i26QUa658su7ucyXKJ7qqbkXENsYZTyR9G9TG9roMnN39oxSmx pnpUcJh3SF5Fq36vhAP4zXeO2CWPAJ6q0w7A6vy46YaJRp0gXteCF0Vww1xUKzOiearF ogxwHX3SjYUqNfI2uvhywoWK+LdRua/v/B98EmYEsRqF3RA/ut8KIdNQfnRAFN9rQQPC Y1KPQeyPRCLjpeunk4CYqXEERxeGhy+Q4D2gPc7b9E8tGBrqP5guW+Prjxv14QUzRIqp ++NOKbJqAG4YKerw5UVIyPu6wHjUNrCqttd0HB72Z633u3CQ6vptZSRG/0qSXFwat8lK vq5w== 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=A9Koh0GsgVCT4pN4yJPa3MEazXKb1HbGcXbrkIuJu84=; b=LXc8KpaWrjA4uF7VgM0uTPiZkREawmH1iTGrDAxiQORJRKBa1PGSZXdjvqh4jRxqLK 5lyHpU7zi569hkheTqFy+fNBoYWMRINcsE8am/V69ogTGpHFvaEFo6lGu3IaqXeWXY6t L2a2L2UWv34DYe5eBBXfbPrO7zkybJPyvAfPcSfrVR5uE8TahzvtCbqTuKMq3/EFr/6M OoeyeI7KSPelWq3g1ti0XILCeCtYoLOI6bCKnlCabn/CPnlGkKnHX4wNGIxnjoUC5oAY d/Ya+REq9cGEE5ITU5SFTN0M4WeYCf0X6hBcbDOKUX2gNo8L9Vo9CPgb+KXDL8xE9HmA CS9Q== X-Gm-Message-State: APjAAAUm4lrH0BUjWDwm0IaJDKyQQOcDOH7WDyyRULnSzCYllhLLVo0v sLE3991DVJHDYns+TV8PcKfD8O51 X-Google-Smtp-Source: APXvYqwAn9PhG51WV0+u8bBUzZr7Q+/AVjkqcTH2tpe/NlUId/KPRDCUW46hZSu7fGR3T37VIonBPw== X-Received: by 2002:a7b:c40c:: with SMTP id k12mr14268922wmi.151.1569233382211; Mon, 23 Sep 2019 03:09:42 -0700 (PDT) Received: from debian.mshome.net (207.148.159.143.dyn.plus.net. [143.159.148.207]) by smtp.gmail.com with ESMTPSA id s10sm18241662wmf.48.2019.09.23.03.09.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Sep 2019 03:09:41 -0700 (PDT) From: Wei Liu X-Google-Original-From: Wei Liu To: Xen Development List Date: Mon, 23 Sep 2019 11:09:30 +0100 Message-Id: <20190923100931.29670-8-liuwe@microsoft.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190923100931.29670-1-liuwe@microsoft.com> References: <20190923100931.29670-1-liuwe@microsoft.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH for-next RFC 7/8] x86: introduce CONFIG_HYPERV and hyperv directory 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_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" We use the same code structure as we did for Xen code. As starters, detect Hyper-V in probe_hyperv. More complex functionality will be added later. Signed-off-by: Wei Liu --- xen/arch/x86/Kconfig | 9 +++++ xen/arch/x86/guest/Makefile | 1 + xen/arch/x86/guest/hyperv/Makefile | 1 + xen/arch/x86/guest/hyperv/hyperv.c | 63 ++++++++++++++++++++++++++++++ xen/arch/x86/guest/hypervisor.c | 3 +- xen/include/asm-x86/guest.h | 1 + xen/include/asm-x86/guest/hyperv.h | 48 +++++++++++++++++++++++ 7 files changed, 125 insertions(+), 1 deletion(-) 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 584bdc1bb8..c5a93babfe 100644 --- a/xen/arch/x86/Kconfig +++ b/xen/arch/x86/Kconfig @@ -163,6 +163,15 @@ endchoice config GUEST bool +config HYPERV_GUEST + def_bool n + select GUEST + prompt "Hyper-V Guest" + ---help--- + Support for Xen detecting when it is running under Hyper-V. + + If unsure, say N. + config XEN_GUEST def_bool n select GUEST 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 += hypervisor.o +subdir-$(CONFIG_HYPERV_GUEST) += hyperv subdir-$(CONFIG_XEN_GUEST) += 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 += 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..488e9c14a3 --- /dev/null +++ b/xen/arch/x86/guest/hyperv/hyperv.c @@ -0,0 +1,63 @@ +/****************************************************************************** + * 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 + +bool __read_mostly hyperv_guest; + +bool __init probe_hyperv(void) +{ + uint32_t eax, ebx, ecx, edx; + + if ( hyperv_guest ) + return true; + + cpuid(0x40000000, &eax, &ebx, &ecx, &edx); + if ( (ebx == 0x7263694d) && /* "Micr" */ + (ecx == 0x666f736f) && /* "osof" */ + (edx == 0x76482074) ) /* "t Hv" */ + hyperv_guest = true; + + return hyperv_guest; +} + +void __init hyperv_setup(void) +{ +} + +void hyperv_ap_setup(void) +{ +} + +void hyperv_resume(void) +{ +} + +/* + * 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/hypervisor.c index fb572b0402..17d56cd05e 100644 --- a/xen/arch/x86/guest/hypervisor.c +++ b/xen/arch/x86/guest/hypervisor.c @@ -37,7 +37,8 @@ void __init probe_hypervisor(void) if ( probe_xen() ) return; - /* Hyper-V probing to follow. */ + if ( probe_hyperv() ) + return; } static void __init init_memmap(void) 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__ #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..30e5135a72 --- /dev/null +++ b/xen/include/asm-x86/guest/hyperv.h @@ -0,0 +1,48 @@ +/****************************************************************************** + * 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 + +extern bool hyperv_guest; + +bool probe_hyperv(void); +void hyperv_setup(void); +void hyperv_ap_setup(void); +void hyperv_resume(void); + +#else + +#define hyperv_guest 0 + +static inline bool probe_hyperv(void) { return false; } + +#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: + */ From patchwork Mon Sep 23 10:09:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Liu X-Patchwork-Id: 11156567 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 528B9112B for ; Mon, 23 Sep 2019 10:11:55 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2E1C820820 for ; Mon, 23 Sep 2019 10:11:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="QKRgf39r" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2E1C820820 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=xen.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iCLIS-0007cE-1I; Mon, 23 Sep 2019 10:10: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 1iCLIQ-0007bP-Ae for xen-devel@lists.xenproject.org; Mon, 23 Sep 2019 10:10:18 +0000 X-Inumbo-ID: 43626438-ddea-11e9-a337-bc764e2007e4 Received: from mail-wr1-x443.google.com (unknown [2a00:1450:4864:20::443]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 43626438-ddea-11e9-a337-bc764e2007e4; Mon, 23 Sep 2019 10:09:43 +0000 (UTC) Received: by mail-wr1-x443.google.com with SMTP id l11so13226060wrx.5 for ; Mon, 23 Sep 2019 03:09:43 -0700 (PDT) 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=Yhsc+HWc7UY9B6qKVRW2bcLWA9bzINIqtexNLDZik88=; b=QKRgf39r53CdG9wwxV68nU2s5oulVwOKADpxfCmy1r1qR9gHBpgv5K5xN5opulNiV6 /htwusVkgpUef7gYdY9ObiFwOKlEwaYHFDdRZOv6Mz0pTSBHhBQEHO8DnOLcLPlm+dmg yQ5zkGENiKEV58SsV9zZ99yCwAfK6egxyRFn/HnzUqY90Z0hXPMB6H7uEooZO0ADoJbA nNZ0jeIFDUGoGw4cEFALnNP+mmHnENxE8UnEm+rc5HnX+biA9PDU8zDfIS7U+ZSEnMB2 7yNDETG08daHxYgH9IDeA8mN7UalWpJk4oS9AHG/m2qBc9FkOBcf6PJIMmcHhzmz6G9b qcZg== 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=Yhsc+HWc7UY9B6qKVRW2bcLWA9bzINIqtexNLDZik88=; b=I139a5GBEiaaYcrC9kI3Lam3pHAJopeD25lY7cKBKCrpKjTvGyWm3N8jNDEFuw/XmJ zOhd1tnEcD6t8UQJvgdFYEs/IZoBZhYyeVvxwpgwq5ZUpa4zt/FGAkYNtJNp76dk+CV7 sGtUynpGyq6Pt+WnnzsQ8fdAhm98Bs4aq2FkPFq5gwNMDq79egqTOWBRzogrn/akVcGA 5gr5lT8V6z5W3FcfuxMDSKZaOp7yvn5zRw7V+VskWJQcFLr+RW28NCzQY+JGf3DcMFpl NFG+TmWixS93ZwI7Lim9RPbpYAyILhVLpyRq5s2hxy2eH1nhPBTBGClmVlA/slnCnQ57 G0XQ== X-Gm-Message-State: APjAAAWVzhKxxhEqCSY4fjXb3zmviUrisvvKgdGq9tIiPKF9Z0Opc284 41yERIiGaUikqCVpoZP4IA+TGiBw X-Google-Smtp-Source: APXvYqz4dzc1WRlkX8HPkBrx46odkk5LysJbmR/OKnNJk/kGwJkrNc0dd9t2LH5yd9MNx8UwxU0x2A== X-Received: by 2002:adf:ed05:: with SMTP id a5mr20955854wro.35.1569233383004; Mon, 23 Sep 2019 03:09:43 -0700 (PDT) Received: from debian.mshome.net (207.148.159.143.dyn.plus.net. [143.159.148.207]) by smtp.gmail.com with ESMTPSA id s10sm18241662wmf.48.2019.09.23.03.09.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Sep 2019 03:09:42 -0700 (PDT) From: Wei Liu X-Google-Original-From: Wei Liu To: Xen Development List Date: Mon, 23 Sep 2019 11:09:31 +0100 Message-Id: <20190923100931.29670-9-liuwe@microsoft.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190923100931.29670-1-liuwe@microsoft.com> References: <20190923100931.29670-1-liuwe@microsoft.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH for-next RFC 8/8] x86: be more verbose when running nested 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_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Signed-off-by: Wei Liu --- xen/arch/x86/setup.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index dec60d0301..bbcc5a503d 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -789,6 +789,17 @@ void __init noreturn __start_xen(unsigned long mbi_p) printk("Xen image load base address: %#lx\n", xen_phys_start); +#ifdef CONFIG_GUEST +#ifdef CONFIG_XEN_GUEST + if ( xen_guest ) + printk("Running on Xen hypervisor\n"); +#endif +#ifdef CONFIG_HYPERV_GUEST + if ( hyperv_guest ) + printk("Running on Hyper-V\n"); +#endif +#endif + #ifdef CONFIG_VIDEO printk("Video information:\n");