From patchwork Mon Sep 30 15:00:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Wei Liu X-Patchwork-Id: 11166841 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 BBA7A112B for ; Mon, 30 Sep 2019 15:02:17 +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 89D2B20679 for ; Mon, 30 Sep 2019 15:02:17 +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="lqH62gJ9" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 89D2B20679 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 1iExAW-00062I-4X; Mon, 30 Sep 2019 15:00:56 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iExAV-000629-91 for xen-devel@lists.xenproject.org; Mon, 30 Sep 2019 15:00:55 +0000 X-Inumbo-ID: 1715d820-e393-11e9-bf31-bc764e2007e4 Received: from mail-wr1-x441.google.com (unknown [2a00:1450:4864:20::441]) by localhost (Halon) with ESMTPS id 1715d820-e393-11e9-bf31-bc764e2007e4; Mon, 30 Sep 2019 15:00:50 +0000 (UTC) Received: by mail-wr1-x441.google.com with SMTP id y19so11749083wrd.3 for ; Mon, 30 Sep 2019 08:00:50 -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=020oWx84yVPrgbu515ga45qtsDGEDvxxJtudgjR7Qeg=; b=lqH62gJ9s/BOdQI6t3ZvAZm2DbGHQ9fEP8j3+yZs17t4GR5EUVbOlFutUJagPrBrky Lxh6urIOzHvv+/vVc6S0/llomI7k6nBgW3trB61H1G1PCzK57I6Mr5hrdhE01ucqjmEp DgoyMi0gyCqaSRDP/BRP6cUSgLJDTIZBF0tCCMIXiE6xfyuZzhx/Wz42zB7jYz6C+7Zx F9ZXr6QEL+8QLD0KGglBk65QL9I2cOCF8Dc4Sii5pvnjUbnaUHyfXaTBbYyYawxGytjg AMUSTFmBeE7EdGIWrotbNIUo2uDq4IVaTJV+2XR1OC22a+sqJkM58MSqjyG4LRGxHKHD wR8Q== 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=020oWx84yVPrgbu515ga45qtsDGEDvxxJtudgjR7Qeg=; b=EN/1+CGdTRKPMU+HHgTUh8CEEByOBRizX6vqcwFz6Axe+jk6W1mB2HBVGRTT3NczZc Z42vT5r8mTEq4317vA8rJnOyWUH4vETqkjf3F+5YvgM5y3Cf4fwfzbuFIU6UJ1qXMExS Vf+0/lVjGt6no/XNdx80KrqhbR0hJ5QfnVhLQEmkdC53UdEVFLZmMLk2GmRGnlyEyLR0 gzRc6bnF+gxaYCGo0uy4EAvcZy7KDe0I1BYkpY8X+DfPeR9hOoWeYUT/NHHUzqYNVWhD txH4BNe5hEN2AZfuWRIYmuYLw7ABbFk8uFKBbvuwGijItkxbJNgey+6sHoxn3DYrgPoR Zdpg== X-Gm-Message-State: APjAAAXrEWufrVycWzt2eq1PgNeSuyXq6qqW1CBhrUoowA5ubcfYe+6W uLtfMLk0tTOcak6w4qvCgeNWinCyJP8= X-Google-Smtp-Source: APXvYqz9hPL3zXmHb5pJI6+l+64sjLmKrXWGfQp0Z14uPyUWcB5PA1l/GVOvMFsyZxx5U7KBfP73/A== X-Received: by 2002:a05:6000:11cb:: with SMTP id i11mr14677491wrx.171.1569855649375; Mon, 30 Sep 2019 08:00:49 -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 f143sm32870852wme.40.2019.09.30.08.00.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Sep 2019 08:00:48 -0700 (PDT) From: Wei Liu X-Google-Original-From: Wei Liu To: Xen Development List Date: Mon, 30 Sep 2019 16:00:35 +0100 Message-Id: <20190930150044.5734-2-liuwe@microsoft.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190930150044.5734-1-liuwe@microsoft.com> References: <20190930150044.5734-1-liuwe@microsoft.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH for-next v2 1/9] 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 30 15:00:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Wei Liu X-Patchwork-Id: 11166857 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 F1AAC112B for ; Mon, 30 Sep 2019 15:03:36 +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 CD89120679 for ; Mon, 30 Sep 2019 15:03:36 +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="ZZE+Smqv" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CD89120679 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 1iExAb-00064E-Js; Mon, 30 Sep 2019 15:01: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 1iExAa-00063o-8v for xen-devel@lists.xenproject.org; Mon, 30 Sep 2019 15:01:00 +0000 X-Inumbo-ID: 17890c50-e393-11e9-8628-bc764e2007e4 Received: from mail-wm1-x329.google.com (unknown [2a00:1450:4864:20::329]) by localhost (Halon) with ESMTPS id 17890c50-e393-11e9-8628-bc764e2007e4; Mon, 30 Sep 2019 15:00:51 +0000 (UTC) Received: by mail-wm1-x329.google.com with SMTP id y21so13130994wmi.0 for ; Mon, 30 Sep 2019 08:00:51 -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=tia3kYMdHxFsxkVNqNvRacsDlGGCJoGWY2kOgcv/rhY=; b=ZZE+Smqv8SKx/lDdt5xSTZ490yyZbQ+bFlQ4eXsPSETZB1yTAd43BVEc48ps8ReY4K bUPw6ScBu+ZqWpS2lRdSwSJq46Yf3TTgi4bswrWq1Huef42UzMYudEg8ChMePTsVY+eK ph+Sv5Fdyc2BI86HNIFwionteFQJwv005TFM27PVlNhi16OpHGXki9uheWZBgQjdDtXG fJzJJMofAHlXJp2GyLfiGOHBA/WqGQzchWtEvUPzmA25IleWqmuCVbsYAeOH7jA3OhlX R7LDrlycTYBAtUSKTWyoMSHnerQDNNL5HwWyMTQbeixzwEgV0KLhVisjC5G6n1PK9kg/ pimA== 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=tia3kYMdHxFsxkVNqNvRacsDlGGCJoGWY2kOgcv/rhY=; b=Qa9iFOhbPB4AmQ8kwYXYXzXEZGfcnzAN3nf4kS1hCvOoJqXvLWZlwIptlBQEBDwimI aJ6j+leGWCL1aW9e2BsMz9OTvNh8aVZv+/owH/6bP086Zcn0lD242ibLmvAHNKGV0Ajx ST/peyAH5SieRb4diuwy+ojcUqCluKP/bhSpIi70w51nRS4hrDat7AUEIElIvxvDfSxs Xx3vjs6GWQyPs+4qyj6LXPG6fRNTY3AqBP1lX3Z6HuWznJVyluo6CMK5xPcutos58Kb5 4PkknTQarGpD6uefMbgOaPT9CxRntUwz7QL+v587hE4apKmucQt144CIy0VASMVokmno 30jA== X-Gm-Message-State: APjAAAUs3SbfwycgC3or/XcgQKf6b2yahr8qmr35q+5SOQSUBLaLhC/v mhWfdf3lufNdetLe/s98yGt766MdKKk= X-Google-Smtp-Source: APXvYqzVQPjIRP7Y+oWe8P+rZLBXPXZStNankz27B3dhmeHqArt0tCCFDM2vFRpX2b6+Bq/oh98ppA== X-Received: by 2002:a7b:c84f:: with SMTP id c15mr18252084wml.52.1569855650185; Mon, 30 Sep 2019 08:00:50 -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 f143sm32870852wme.40.2019.09.30.08.00.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Sep 2019 08:00:49 -0700 (PDT) From: Wei Liu X-Google-Original-From: Wei Liu To: Xen Development List Date: Mon, 30 Sep 2019 16:00:36 +0100 Message-Id: <20190930150044.5734-3-liuwe@microsoft.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190930150044.5734-1-liuwe@microsoft.com> References: <20190930150044.5734-1-liuwe@microsoft.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH for-next v2 2/9] 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 30 15:00:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Wei Liu X-Patchwork-Id: 11166859 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 9FECC17E1 for ; Mon, 30 Sep 2019 15:03: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 7B4AF20815 for ; Mon, 30 Sep 2019 15:03: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="QWCngJ8/" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7B4AF20815 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 1iExAf-00066q-Un; Mon, 30 Sep 2019 15:01:05 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iExAf-00066W-9L for xen-devel@lists.xenproject.org; Mon, 30 Sep 2019 15:01:05 +0000 X-Inumbo-ID: 17f62498-e393-11e9-bf31-bc764e2007e4 Received: from mail-wm1-x343.google.com (unknown [2a00:1450:4864:20::343]) by localhost (Halon) with ESMTPS id 17f62498-e393-11e9-bf31-bc764e2007e4; Mon, 30 Sep 2019 15:00:51 +0000 (UTC) Received: by mail-wm1-x343.google.com with SMTP id r19so13811461wmh.2 for ; Mon, 30 Sep 2019 08:00:51 -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=LzVJRQ/OrflFRie8Ab9jbbnlLHJRH6wdZOJqJE01vJw=; b=QWCngJ8/XkswncojFmlONEG7f/xnyHvnDnF32o87+RnyzmzLBoWbXe1yMV4sSMXpLK 41eVihLu+X7vufHY4sNmzo9fyaIhvopBLW+s4rx2mT/Yz+RIo2VSiSw3rhYpXzsrJJgy EYHT16mT30yXopxzE1BGgURTHsBXC4CwEYZMaJusU0v1hKh2iFJGtK/JMXPAWD4pCny8 drvgvIMQHQa3psuAr7ghy+QbJJIdRidOwpgWoSWL+p9qxJXXPp1J+oRHy5+IYKOsK6rz +nEkTVABzDemfO9z9MdgAq/xEzVXQwTcX/LTdPyYvk6GWifGef/rVOLpz3jSI5rtvy2K ERmQ== 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=LzVJRQ/OrflFRie8Ab9jbbnlLHJRH6wdZOJqJE01vJw=; b=OVqjWDlPLLixpoY7A9/Ckjb/EFhMJXYSaWTen/xtNcouDa+NTGZS14924kSco/ZBJY jImbEPYO+rHExPHs19skF/BfKxBcpPWG9khyKs/HitvAF/jY1HLanK66R+Co/RGoExSW ZUvGGHFlj96voJtiC4+xcZR00y0MTsGzRB65j3j2WgQE0tmq/opcs3rzqvxCNmQlqYEf u9LvzflQpT99U66duSFSE/1HoD3eegJcKUEIcIhJarX2tTHxwyrJb5qfGNIfWLDWn5hQ g0yXnForIcnUL27o5r/2tstd481SasuzmObKkDeVp3ouslFFI2iPSKLisEnSIhS2KF3w WtEQ== X-Gm-Message-State: APjAAAVMKsySZKlqGOIza0xYkJYLHfivPTktujJw9qXwGjHoLjHFL6bg XxOTs7z4/Q4UKUVPX+wZ8M46UNMkQRM= X-Google-Smtp-Source: APXvYqzMvcdlLd0G6M6+KMjNP0aVwbOs2w0mcIOG/KOndkFHevClPCLWkJlNxpZKoEcnIa7mrDQp0w== X-Received: by 2002:a1c:cb05:: with SMTP id b5mr17220096wmg.79.1569855650906; Mon, 30 Sep 2019 08:00:50 -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 f143sm32870852wme.40.2019.09.30.08.00.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Sep 2019 08:00:50 -0700 (PDT) From: Wei Liu X-Google-Original-From: Wei Liu To: Xen Development List Date: Mon, 30 Sep 2019 16:00:37 +0100 Message-Id: <20190930150044.5734-4-liuwe@microsoft.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190930150044.5734-1-liuwe@microsoft.com> References: <20190930150044.5734-1-liuwe@microsoft.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH for-next v2 3/9] 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 5edbcd9ac5..5441e89de2 100644 --- a/xen/arch/x86/pv/shim.c +++ b/xen/arch/x86/pv/shim.c @@ -990,7 +990,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 30 15:00:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Wei Liu X-Patchwork-Id: 11166845 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 EBF3C112B for ; Mon, 30 Sep 2019 15:02:23 +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 C7B3220679 for ; Mon, 30 Sep 2019 15:02:23 +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="tttOOIaA" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C7B3220679 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 1iExAl-00069A-9e; Mon, 30 Sep 2019 15:01:11 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iExAk-00068o-9V for xen-devel@lists.xenproject.org; Mon, 30 Sep 2019 15:01:10 +0000 X-Inumbo-ID: 186031bc-e393-11e9-8628-bc764e2007e4 Received: from mail-wm1-x343.google.com (unknown [2a00:1450:4864:20::343]) by localhost (Halon) with ESMTPS id 186031bc-e393-11e9-8628-bc764e2007e4; Mon, 30 Sep 2019 15:00:52 +0000 (UTC) Received: by mail-wm1-x343.google.com with SMTP id y21so13131115wmi.0 for ; Mon, 30 Sep 2019 08:00:52 -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=uREt8Z5nJzR7OIiuZjnYzLQFQ7JxWM6N+fEC7IgLHk0=; b=tttOOIaA8l32h8h53UtQE8kxKmCmVsqtvbR7S83xuyshl+ELlQA5u0j1Y14ngSjKl4 RSAY7FbLr987OhmNs9GiDs0RMW2ttUszHpGOWEBFmNI66xODzzQboa6m5HWPMu/O78ua HqjAANalJYxWj89MbKqdF3sj/gO9qyv0fL7KJLWQMuB8xtDonvisDgQQ3xB28dAm7/bf +rwiOmlPPB66A3eoeBDOSLyvaU2Tf4gbEJaNFRjjatbislagd+bEeLBMcX+1B0/BWx0j NG436K47ts2lY8RQc2Erzsnez+m3kYlGtyXsvJIPWHJtvmmjkC/SOXiQSW5xyeFSJcCR QN6w== 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=uREt8Z5nJzR7OIiuZjnYzLQFQ7JxWM6N+fEC7IgLHk0=; b=V34GrZ4QH0DlglFonQfR2Le4Xxqw65Ka79/SGYIXAjpsX4dAf8jnVPckvnR+vKQQj9 LgFzKWRP6hR+OupJua84AWqVnK29s0sanoOGaCsy4L5kcbkqOFT/HmsHnc5Gcc78rU3P hswl9Dbx7A9A+018Qxbe4xNUu+la8CvRIeGR9XX7AqD2TUTdC6kKXyZsr7PmImnCoc6K Yfp3yg/PJ8EXz5Y5L5CIANCwA95kS0uQDfuVX2oGJrXe+u/O+dM4VF3pjTLF6TNh+RxT 6Q+wFdbC7rvfisnfPfTnA/ilH7Qn8u4Cz7oa9X4BQsUWLpwdf+naJ2RUgePPKyYECO/8 t9qg== X-Gm-Message-State: APjAAAXkj5zVBxTlL2XvdnwbWYL80Am+Z6WQ9xODXpGyL4VTivoX/rBa YYnzP9vXu6gm0nSE0MEwLhGbS3eYjqs= X-Google-Smtp-Source: APXvYqyiW5bip7TIiPgZOaJKzQMeaGJP70CI/jnP85VTJyCHEDVTfuIRllPaACUhoZh1tvfJiTq/kg== X-Received: by 2002:a1c:1981:: with SMTP id 123mr17182414wmz.88.1569855651629; Mon, 30 Sep 2019 08:00:51 -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 f143sm32870852wme.40.2019.09.30.08.00.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Sep 2019 08:00:51 -0700 (PDT) From: Wei Liu X-Google-Original-From: Wei Liu To: Xen Development List Date: Mon, 30 Sep 2019 16:00:38 +0100 Message-Id: <20190930150044.5734-5-liuwe@microsoft.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190930150044.5734-1-liuwe@microsoft.com> References: <20190930150044.5734-1-liuwe@microsoft.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH for-next v2 4/9] x86: include xen/lib.h in guest/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" We need ASSERT_UNREACHABLE. 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 c9deca6ffc..d0d2f5022d 100644 --- a/xen/include/asm-x86/guest/hypercall.h +++ b/xen/include/asm-x86/guest/hypercall.h @@ -182,6 +182,8 @@ static inline long xen_hypercall_set_evtchn_upcall_vector( #else /* CONFIG_XEN_GUEST */ +#include + #include static inline void xen_hypercall_console_write( From patchwork Mon Sep 30 15:00:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Liu X-Patchwork-Id: 11166847 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 3DA9E13B1 for ; Mon, 30 Sep 2019 15:02:35 +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 19C7A20679 for ; Mon, 30 Sep 2019 15:02:35 +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="m6MWzgzB" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 19C7A20679 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 1iExAq-0006Bm-Jd; Mon, 30 Sep 2019 15:01:16 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iExAp-0006BG-9j for xen-devel@lists.xenproject.org; Mon, 30 Sep 2019 15:01:15 +0000 X-Inumbo-ID: 18f13e6e-e393-11e9-bf31-bc764e2007e4 Received: from mail-wr1-x441.google.com (unknown [2a00:1450:4864:20::441]) by localhost (Halon) with ESMTPS id 18f13e6e-e393-11e9-bf31-bc764e2007e4; Mon, 30 Sep 2019 15:00:53 +0000 (UTC) Received: by mail-wr1-x441.google.com with SMTP id h7so11746459wrw.8 for ; Mon, 30 Sep 2019 08:00:53 -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=jBrEUmLmtAmRmL0ZQe75O+VGK/lIBJ2eQ4PSZ4jPdH0=; b=m6MWzgzBfJhXOKh+t5/3eA6RsAMf5EOQdP83nwfOg+Jqv4vNftDY3jSEa1TfhNF8fm pmvw0aHqOpSeN6Pk0gok9ltaOrukUqVzSQ5WSx55W62BInQQiCaTCX1cJanXSKEqYh5E gRXeoVOifiZOGaftSghxf2BytgneZjrWfbgy5GkdSaI6cACj6LnGI+w2bKgiWpQna5+1 Y0PelY3F4Eruf6GiLbYWQyg8QklJ2Qkm101S1d9SQ158fru7LF+N3836ffcG712wcWqQ /5EGK3pNlSP9HZN3N2cvjhCtr5YG0BeNsgQjtEUruQIT6c7ajA/nYHwC7nHImmDhZ6js LULg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=jBrEUmLmtAmRmL0ZQe75O+VGK/lIBJ2eQ4PSZ4jPdH0=; b=po4QUK4toGLDVG7UdMsHzO084xHfQaSJq8T/du6ns3sS/oL0ZiQwBhnzXbK1LZmTLI APyB0eBj4KPfgU5MqQ41Ho9lepal9weEpP3tzRUJifM3htD06Tydt7Pw/PTCh1ZtqbRn o7Ul4hPqWICgLKFzojJ3FS1LDGJTNRdcw1u7rdnMxtkYDg/UddXK0rU4/xoWTaUM7IQA m2slg0rqgFlpnb3pUkG64PhmSzc3jnmcli1FSczlxwY6aCEDCT8ZchPcRjsm5ziTzrQE kvaALM4pTEkIxLeSjo0UG006Eac9InKf9YBgHZ3pseINnK8ZdxSbM6TtS6IdHlKG7BfN Ntjg== X-Gm-Message-State: APjAAAXaf5ri0vTc2ruueAZV1wd7RVotQxlWFdBKLGdBQePFJsdP7kTf jpIRPZhFIxifRrVSWW34AyUgJMCJgg4= X-Google-Smtp-Source: APXvYqwhXMRcnQ4crkziMurYZ2VZh8DTU6KYKuTROLbsX7plOy1Pv6yV8Omj8O3CN8ZMQRykDNBE+g== X-Received: by 2002:adf:e988:: with SMTP id h8mr13603675wrm.354.1569855652462; Mon, 30 Sep 2019 08:00:52 -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 f143sm32870852wme.40.2019.09.30.08.00.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Sep 2019 08:00:51 -0700 (PDT) From: Wei Liu X-Google-Original-From: Wei Liu To: Xen Development List Date: Mon, 30 Sep 2019 16:00:39 +0100 Message-Id: <20190930150044.5734-6-liuwe@microsoft.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190930150044.5734-1-liuwe@microsoft.com> References: <20190930150044.5734-1-liuwe@microsoft.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH for-next v2 5/9] x86: introduce hypervisor framework X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Wei Liu , Wei Liu , Andrew Cooper , Michael Kelley , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" 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 --- xen/arch/x86/guest/Makefile | 2 + xen/arch/x86/guest/hypervisor.c | 45 +++++++++++++++++++ xen/include/asm-x86/guest.h | 1 + xen/include/asm-x86/guest/hypervisor.h | 61 ++++++++++++++++++++++++++ xen/include/asm-x86/guest/xen.h | 12 ----- 5 files changed, 109 insertions(+), 12 deletions(-) create mode 100644 xen/arch/x86/guest/hypervisor.c create mode 100644 xen/include/asm-x86/guest/hypervisor.h diff --git a/xen/arch/x86/guest/Makefile b/xen/arch/x86/guest/Makefile index 6806f04947..f63d64bbee 100644 --- a/xen/arch/x86/guest/Makefile +++ b/xen/arch/x86/guest/Makefile @@ -1 +1,3 @@ +obj-y += 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..89b9ae4de0 --- /dev/null +++ b/xen/arch/x86/guest/hypervisor.c @@ -0,0 +1,45 @@ +/****************************************************************************** + * arch/x86/guest/hypervisor.c + * + * Support for detecting and running under a hypervisor. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; If not, see . + * + * Copyright (c) 2019 Microsoft. + */ + +#include + +#include +#include + +static struct hypervisor_ops *hops __read_mostly; + +bool hypervisor_probe(void) +{ + if ( hops ) + return true; + + return false; +} + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/xen/include/asm-x86/guest.h b/xen/include/asm-x86/guest.h index a38c6b5b3f..8e167165ae 100644 --- a/xen/include/asm-x86/guest.h +++ b/xen/include/asm-x86/guest.h @@ -20,6 +20,7 @@ #define __X86_GUEST_H__ #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..38344e2e89 --- /dev/null +++ b/xen/include/asm-x86/guest/hypervisor.h @@ -0,0 +1,61 @@ +/****************************************************************************** + * asm-x86/guest/hypervisor.h + * + * This program is free software; you can redistribute it and/or + * modify it under the terms and conditions of the GNU General Public + * License, version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; If not, see . + * + * Copyright (c) 2019 Microsoft. + */ + +#ifndef __X86_HYPERVISOR_H__ +#define __X86_HYPERVISOR_H__ + +#ifdef CONFIG_GUEST + +struct hypervisor_ops { + /* Name of the hypervisor */ + const char *name; + /* Main setup routine */ + void (*setup)(void); + /* AP setup */ + void (*ap_setup)(void); + /* Resume from suspension */ + void (*resume)(void); +}; + +bool hypervisor_probe(void); +void hypervisor_setup(void); +void hypervisor_ap_setup(void); +void hypervisor_resume(void); + +#else + +#include + +static inline bool hypervisor_probe(void) { return false; } +static inline void hypervisor_setup(void) {} +static inline void hypervisor_ap_setup(void) {} +static inline void hypervisor_resume(void) {} + +#endif /* CONFIG_GUEST */ + +#endif /* __X86_HYPERVISOR_H__ */ + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/xen/include/asm-x86/guest/xen.h b/xen/include/asm-x86/guest/xen.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; 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); 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); 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_XEN_GUEST */ #endif /* __X86_GUEST_XEN_H__ */ From patchwork Mon Sep 30 15:00:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Wei Liu X-Patchwork-Id: 11166849 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 7010E112B for ; Mon, 30 Sep 2019 15:02:50 +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 4C16020679 for ; Mon, 30 Sep 2019 15:02:50 +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="W4jAwl1S" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4C16020679 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 1iExAv-0006EM-Vo; Mon, 30 Sep 2019 15:01:21 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iExAu-0006Da-A1 for xen-devel@lists.xenproject.org; Mon, 30 Sep 2019 15:01:20 +0000 X-Inumbo-ID: 1972c15a-e393-11e9-bf31-bc764e2007e4 Received: from mail-wm1-x32b.google.com (unknown [2a00:1450:4864:20::32b]) by localhost (Halon) with ESMTPS id 1972c15a-e393-11e9-bf31-bc764e2007e4; Mon, 30 Sep 2019 15:00:54 +0000 (UTC) Received: by mail-wm1-x32b.google.com with SMTP id a6so13796336wma.5 for ; Mon, 30 Sep 2019 08:00:54 -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=+NBwsgPo14hF2SBE5SphMAPpppnQLhW6kJgfDwP7ses=; b=W4jAwl1SnUJ1WI6MrUDQ/d2/6Jtxu//of+9egZ5uC+FLUPmXrxVhgMEPVfNFRWU04j neni1af4BcOs1ZMbw8OPImHmR0jEso5MS+aIbjCkB/xf1xztqi3QdOoBd+k4B/jmeI/u VWaNN1ug65fQC8ARtCDGamj+5o3S1YWGq1zbxVsNqQtSSa6IKYMOqC8JJi4ee3OpXMlW AYdjTL1I0CxRgvHc3vf5JVuSUAMGrCovjBUQzvUtfi0bpb+cra6ORa8lKXZIc4fT2YBs 0nzf7OIkohWeRg+bz90lp9d9/Zi6zc4hWHc7qx/W7RQo6a6sPNW3Bv+xBmC7okNAcdqT 5+1Q== 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=+NBwsgPo14hF2SBE5SphMAPpppnQLhW6kJgfDwP7ses=; b=EOKtV3WBJ30WqhfuHko4z7q71/HQLShOS37BWMrrGn7dbpYfJ018ZGqk7gIk76Pmm8 8jfVSX/EkPFsDCvtSVuQ1BJ0AS+31KnrXLNkIs4kcPacySc0LJlUW4r7OVHu7OzBVwhp Si1T991eCerEq8+Wg/DVcrpKXkRtvahaQiAIIiknjTEOmO+G6qOdrxJXQkebjedN+9os LtREzZrscOWQCuenQzMNAgE3+5xBah4koDv4lqFOuGL8W0IMHoWCqf6Kg9BYeaEBkPJr cBbqE258xpHriGHKDHZnOBNfL50Q+Qt7yZma8b/BhzS10U0cv/wodlfpZEWZTzVqg/M5 EzEA== X-Gm-Message-State: APjAAAXLG8S1XgZ3DHUuyOAeoTX7SWhFf/XY5sPU5g8xN1r2jyxYMBEW jrPYvOGTxGgYGIYYAA8L/6QQt8RyTXw= X-Google-Smtp-Source: APXvYqzQzmzlaqThHgVzqWeq6cGav5gQKngdTV2wVijSIvjWxCcXYrj5dA/5iV/c64qp47zlqudevA== X-Received: by 2002:a1c:a516:: with SMTP id o22mr18764974wme.116.1569855653373; Mon, 30 Sep 2019 08:00:53 -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 f143sm32870852wme.40.2019.09.30.08.00.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Sep 2019 08:00:52 -0700 (PDT) From: Wei Liu X-Google-Original-From: Wei Liu To: Xen Development List Date: Mon, 30 Sep 2019 16:00:40 +0100 Message-Id: <20190930150044.5734-7-liuwe@microsoft.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190930150044.5734-1-liuwe@microsoft.com> References: <20190930150044.5734-1-liuwe@microsoft.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH for-next v2 6/9] 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_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" They are used in Xen code only. No functional change. Signed-off-by: Wei Liu Reviewed-by: Roger Pau Monné --- 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 78fc603996..9895025d02 100644 --- a/xen/arch/x86/guest/xen/xen.c +++ b/xen/arch/x86/guest/xen/xen.c @@ -97,7 +97,7 @@ static void map_shared_info(void) unsigned int i; unsigned long rc; - if ( hypervisor_alloc_unused_page(&mfn) ) + if ( xen_alloc_unused_page(&mfn) ) panic("unable to reserve shared info memory page\n"); xatp.gpfn = mfn_x(mfn); @@ -284,7 +284,7 @@ void hypervisor_ap_setup(void) init_evtchn(); } -int hypervisor_alloc_unused_page(mfn_t *mfn) +int xen_alloc_unused_page(mfn_t *mfn) { unsigned long m; int rc; @@ -296,7 +296,7 @@ int hypervisor_alloc_unused_page(mfn_t *mfn) return rc; } -int hypervisor_free_unused_page(mfn_t mfn) +int xen_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 5441e89de2..41b4665649 100644 --- a/xen/arch/x86/pv/shim.c +++ b/xen/arch/x86/pv/shim.c @@ -739,7 +739,7 @@ static long pv_shim_grant_table_op(unsigned int cmd, }; mfn_t mfn; - rc = hypervisor_alloc_unused_page(&mfn); + rc = xen_alloc_unused_page(&mfn); if ( rc ) { gprintk(XENLOG_ERR, @@ -751,7 +751,7 @@ static long pv_shim_grant_table_op(unsigned int cmd, rc = xen_hypercall_memory_op(XENMEM_add_to_physmap, &xatp); if ( rc ) { - hypervisor_free_unused_page(mfn); + xen_free_unused_page(mfn); break; } diff --git a/xen/include/asm-x86/guest/xen.h b/xen/include/asm-x86/guest/xen.h index 3145f75361..8221fc1325 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; void probe_hypervisor(void); -int hypervisor_alloc_unused_page(mfn_t *mfn); -int hypervisor_free_unused_page(mfn_t mfn); +int xen_alloc_unused_page(mfn_t *mfn); +int xen_free_unused_page(mfn_t mfn); DECLARE_PER_CPU(unsigned int, vcpu_id); DECLARE_PER_CPU(struct vcpu_info *, vcpu_info); From patchwork Mon Sep 30 15:00:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Liu X-Patchwork-Id: 11166853 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 7927917E1 for ; Mon, 30 Sep 2019 15:02:54 +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 54DFE20679 for ; Mon, 30 Sep 2019 15:02:54 +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="qLOAOvCI" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 54DFE20679 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 1iExB0-0006Hc-GQ; Mon, 30 Sep 2019 15:01:26 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iExAz-0006Gg-A5 for xen-devel@lists.xenproject.org; Mon, 30 Sep 2019 15:01:25 +0000 X-Inumbo-ID: 1a05aeb6-e393-11e9-bf31-bc764e2007e4 Received: from mail-wm1-x344.google.com (unknown [2a00:1450:4864:20::344]) by localhost (Halon) with ESMTPS id 1a05aeb6-e393-11e9-bf31-bc764e2007e4; Mon, 30 Sep 2019 15:00:55 +0000 (UTC) Received: by mail-wm1-x344.google.com with SMTP id i16so13822999wmd.3 for ; Mon, 30 Sep 2019 08:00:55 -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=a308ntinwpL4Pj6W865uoP3o199pogJ2D+pJjfZRU2s=; b=qLOAOvCI+og68vS9ESuVGdkyJQGjZv/nKxvTqyKBGJ2r0TXBvNaG9rfKVTowdMQBjT IB2mr46m81/SUg7TGH56DjD8e1OoroO9ca+H4jZ3CL/x0b9AmqBsQUccyn1Xb+Z5OYBa 1oggNCf+db8nM1q/NOksH/VcIMNNAiszgeddLF+fBJa2ylxsSpYRHTt8y3/gemzSxHpB xUxBCObcaSPqa6HW1FPjiQBdVeSC4LAzmP+DHTZ3l4iqFz4adjgks+6iOCuTauOhIlwP 9lappxZ9/W+VcSyOmLWdndSIrSaIujptPV2SpQmIs+ehIGXOqIdlS7JNhea+xIhCYL80 jFTQ== 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=a308ntinwpL4Pj6W865uoP3o199pogJ2D+pJjfZRU2s=; b=uHn3jhmmTITivwcTxD/VO8ZCzJwM/9VitrKpzhDCrxMbyrFcGJdcIl30dZx2mjxqLZ zPdKHb6ZcM4wX3F+585y1+aiMDltHDCJtIftYAaeiRGWTIqjVOQhHaLsX/qW0cwVPQ22 jCS6Ox6184pICSDMdv7SU28+wu7V07BTBcUbcOFZLMWtOiKgdFw9S5cPeNBPssjg/BrJ gBiH55b6dItJ4y1fgtkjzvC9T3oBsYv9h9/fut5ZqQiXxdfHWb9xcrNKAx3VYdMMDfaD lwqPjEGH+sspGr2dBQRECD4kp2PrB3Ig+M6K2Ov0j6e8j/HUu3BuK4FxLAy9jrupCX3B yCnA== X-Gm-Message-State: APjAAAWLieFfdf09Mdcc5St6jX7naBaEHooPeHdqVaYOmU+FyZdv82RX 0rqoFbSz6PxzlOuJ5z6AMN9n3ngH3VA= X-Google-Smtp-Source: APXvYqzIoW+IuIjTcy+WXY3rSGLoxs9VhNjko6vLC5wtU3E+wQMbeYbe33j59KHY8nWapZHgUehRgg== X-Received: by 2002:a05:600c:2386:: with SMTP id m6mr18144223wma.164.1569855654133; Mon, 30 Sep 2019 08:00:54 -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 f143sm32870852wme.40.2019.09.30.08.00.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Sep 2019 08:00:53 -0700 (PDT) From: Wei Liu X-Google-Original-From: Wei Liu To: Xen Development List Date: Mon, 30 Sep 2019 16:00:41 +0100 Message-Id: <20190930150044.5734-8-liuwe@microsoft.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190930150044.5734-1-liuwe@microsoft.com> References: <20190930150044.5734-1-liuwe@microsoft.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH for-next v2 7/9] x86: switch xen 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_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Take the chance to change probe_hypervisor to hypervisor_probe. Signed-off-by: Wei Liu --- xen/arch/x86/guest/hypervisor.c | 31 +++++++++++++++++++++++++++++-- xen/arch/x86/guest/xen/pvh-boot.c | 2 +- xen/arch/x86/guest/xen/xen.c | 26 ++++++++++++++------------ xen/arch/x86/setup.c | 2 +- xen/include/asm-x86/guest/xen.h | 6 ++++-- 5 files changed, 49 insertions(+), 18 deletions(-) diff --git a/xen/arch/x86/guest/hypervisor.c b/xen/arch/x86/guest/hypervisor.c index 89b9ae4de0..30453b6a7a 100644 --- a/xen/arch/x86/guest/hypervisor.c +++ b/xen/arch/x86/guest/hypervisor.c @@ -22,7 +22,7 @@ #include #include -#include +#include static struct hypervisor_ops *hops __read_mostly; @@ -31,7 +31,34 @@ bool hypervisor_probe(void) if ( hops ) return true; - return false; + /* Too early to use cpu_has_hypervisor */ + if ( !(cpuid_ecx(1) & cpufeat_mask(X86_FEATURE_HYPERVISOR)) ) + return false; + +#ifdef CONFIG_XEN_GUEST + if ( xen_probe() ) + hops = &xen_hypervisor_ops; +#endif + + return !!hops; +} + +void 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(); } /* 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); - probe_hypervisor(); + hypervisor_probe(); ASSERT(xen_guest); get_memory_map(); diff --git a/xen/arch/x86/guest/xen/xen.c b/xen/arch/x86/guest/xen/xen.c index 9895025d02..a9d321e5eb 100644 --- a/xen/arch/x86/guest/xen/xen.c +++ b/xen/arch/x86/guest/xen/xen.c @@ -67,24 +67,19 @@ static void __init find_xen_leaves(void) } } -void __init probe_hypervisor(void) +bool __init xen_probe(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 ) - 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) @@ -249,7 +244,7 @@ static void init_evtchn(void) } } -void __init hypervisor_setup(void) +void __init xen_setup(void) { init_memmap(); @@ -277,7 +272,7 @@ void __init hypervisor_setup(void) init_evtchn(); } -void hypervisor_ap_setup(void) +void xen_ap_setup(void) { set_vcpu_id(); map_vcpuinfo(); @@ -307,7 +302,7 @@ static void ap_resume(void *unused) init_evtchn(); } -void hypervisor_resume(void) +void xen_resume(void) { /* Reset shared info page. */ map_shared_info(); @@ -330,6 +325,13 @@ void hypervisor_resume(void) pv_console_init(); } +struct hypervisor_ops xen_hypervisor_ops = { + .name = "Xen", + .setup = xen_setup, + .ap_setup = xen_ap_setup, + .resume = xen_resume, +}; + /* * Local variables: * mode: C diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index dec60d0301..0ee11b15a6 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(); - probe_hypervisor(); + hypervisor_probe(); parse_video_info(); diff --git a/xen/include/asm-x86/guest/xen.h b/xen/include/asm-x86/guest/xen.h index 8221fc1325..7401c80a1a 100644 --- a/xen/include/asm-x86/guest/xen.h +++ b/xen/include/asm-x86/guest/xen.h @@ -23,6 +23,7 @@ #include #include +#include #define XEN_shared_info ((struct shared_info *)fix_to_virt(FIX_XEN_SHARED_INFO)) @@ -31,8 +32,9 @@ extern bool xen_guest; extern bool pv_console; extern uint32_t xen_cpuid_base; +extern struct hypervisor_ops xen_hypervisor_ops; -void probe_hypervisor(void); +bool xen_probe(void); int xen_alloc_unused_page(mfn_t *mfn); int xen_free_unused_page(mfn_t mfn); @@ -44,7 +46,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 bool xen_probe(void) { return false; } #endif /* CONFIG_XEN_GUEST */ #endif /* __X86_GUEST_XEN_H__ */ From patchwork Mon Sep 30 15:00:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Liu X-Patchwork-Id: 11166851 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 4C26B13B1 for ; Mon, 30 Sep 2019 15:02:54 +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 2778320679 for ; Mon, 30 Sep 2019 15:02:54 +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="RnaBNo+g" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2778320679 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 1iExB5-0006Kh-Rj; Mon, 30 Sep 2019 15:01:31 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iExB4-0006Jo-AF for xen-devel@lists.xenproject.org; Mon, 30 Sep 2019 15:01:30 +0000 X-Inumbo-ID: 1a8a1548-e393-11e9-8628-bc764e2007e4 Received: from mail-wm1-x343.google.com (unknown [2a00:1450:4864:20::343]) by localhost (Halon) with ESMTPS id 1a8a1548-e393-11e9-8628-bc764e2007e4; Mon, 30 Sep 2019 15:00:56 +0000 (UTC) Received: by mail-wm1-x343.google.com with SMTP id m18so13137365wmc.1 for ; Mon, 30 Sep 2019 08:00:56 -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=iyiOgqrZxFUGRGfUCjGuZn7FzXfpH61oMe3dzY2NCCg=; b=RnaBNo+g88s5ScTLq1f9UR5Pwr2m+NZAzF0m/CeCOp5JXdWutjRcUNGDSpcQoV3exO oC7JA8k8SrwAZKA82J4F/rNfg3Wc9wH4gqjEogFYo2rNaceLdmEoDPCGxkFxr67J0VMo uiNirK7/qH2MvLPciOw3gapnceYwuboXyI/370E219yjOv40rKt0ZajHbN343MWxdJPn JQIlvGnozFayU6EwL+B3vgBe9TJLkPfxpldx2/dOG7ufKfHb6DrxxvjJWcDOc28pFRRr /KsB/Nh9rBCB7LBf9L9W6UezZXUJopya1DKUbAimmFmgvNpme5m9W/RJRtJIBu2HCf13 z0Vw== 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=iyiOgqrZxFUGRGfUCjGuZn7FzXfpH61oMe3dzY2NCCg=; b=CMAFEPfUif1+hbWBLEB62KGE5oOW/H3kJAWWt+KhygMqePYlRk38MC9n9Wabgbv3Gl FA0JzxSAcIToK+HzmCt4QlZ28YkujtJb+0VZhJYbQghL3plMRyYWatQtf7/Pwcg6P4Hc pLGZZLaYSalMjwdOaboFXkgubDTTncvdfpkRllnITMnQYySWXHBPQUI2oSY6Dc/gh2MP nIGr5kOz+mUTc9r+E/tkKa9Vfd62lQX+dbazxWXBJNAznJYHv7O0dukiVerQcJ4oZpzZ 0uwUKk6WEYNm8FNSHScDwUMsEdmQiW7OVS4Yo7zPYA0F0hcawk2VjAJ4UJUJJ/ce9LD1 Rp0g== X-Gm-Message-State: APjAAAXJfbbFLPZ6gcgQWcI5lsp1WWBjNKfHBdHE+BNMxU790cf4oXev LDfDIh2feHlImzziYsXRPTwW3Y5GQUE= X-Google-Smtp-Source: APXvYqwOBR+rM15fjyUePABCbF2i3PLVBkhYoBDStz+QB1AflVfmXILzGTjTV/v2KZF7/+s1yh4QSA== X-Received: by 2002:a1c:c506:: with SMTP id v6mr16406444wmf.160.1569855655190; Mon, 30 Sep 2019 08:00:55 -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 f143sm32870852wme.40.2019.09.30.08.00.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Sep 2019 08:00:54 -0700 (PDT) From: Wei Liu X-Google-Original-From: Wei Liu To: Xen Development List Date: Mon, 30 Sep 2019 16:00:42 +0100 Message-Id: <20190930150044.5734-9-liuwe@microsoft.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190930150044.5734-1-liuwe@microsoft.com> References: <20190930150044.5734-1-liuwe@microsoft.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH for-next v2 8/9] 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_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Signed-off-by: Wei Liu --- xen/arch/x86/guest/hypervisor.c | 5 +++++ xen/arch/x86/setup.c | 6 +++++- xen/include/asm-x86/guest/hypervisor.h | 2 ++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/xen/arch/x86/guest/hypervisor.c b/xen/arch/x86/guest/hypervisor.c index 30453b6a7a..8161b26c5a 100644 --- a/xen/arch/x86/guest/hypervisor.c +++ b/xen/arch/x86/guest/hypervisor.c @@ -43,6 +43,11 @@ bool hypervisor_probe(void) return !!hops; } +const char *hypervisor_name(void) +{ + return hops->name; +} + void hypervisor_setup(void) { if ( hops && hops->setup ) diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 0ee11b15a6..cf5a7b8e1e 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -689,6 +689,7 @@ void __init noreturn __start_xen(unsigned long mbi_p) int i, j, e820_warn = 0, bytes = 0; bool acpi_boot_table_init_done = false, relocated = false; int ret; + bool running_on_hypervisor; struct ns16550_defaults ns16550 = { .data_bits = 8, .parity = 'n', @@ -763,7 +764,7 @@ void __init noreturn __start_xen(unsigned long mbi_p) * allocing any xenheap structures wanted in lower memory. */ kexec_early_calculations(); - hypervisor_probe(); + running_on_hypervisor = hypervisor_probe(); parse_video_info(); @@ -789,6 +790,9 @@ void __init noreturn __start_xen(unsigned long mbi_p) printk("Xen image load base address: %#lx\n", xen_phys_start); + if ( running_on_hypervisor ) + printk("Running on %s\n", hypervisor_name()); + #ifdef CONFIG_VIDEO printk("Video information:\n"); diff --git a/xen/include/asm-x86/guest/hypervisor.h b/xen/include/asm-x86/guest/hypervisor.h index 38344e2e89..a7d75bf9cf 100644 --- a/xen/include/asm-x86/guest/hypervisor.h +++ b/xen/include/asm-x86/guest/hypervisor.h @@ -36,6 +36,7 @@ bool hypervisor_probe(void); void hypervisor_setup(void); void hypervisor_ap_setup(void); void hypervisor_resume(void); +const char *hypervisor_name(void); #else @@ -45,6 +46,7 @@ static inline bool hypervisor_probe(void) { return false; } static inline void hypervisor_setup(void) {} static inline void hypervisor_ap_setup(void) {} static inline void hypervisor_resume(void) {} +static inline char *hypervisor_name(void) { return NULL; } #endif /* CONFIG_GUEST */ From patchwork Mon Sep 30 15:00:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Liu X-Patchwork-Id: 11166855 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 958E8112B for ; Mon, 30 Sep 2019 15:03:04 +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 7091F20679 for ; Mon, 30 Sep 2019 15:03:04 +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="qtS87TNU" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7091F20679 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 1iExBA-0006Nv-8s; Mon, 30 Sep 2019 15:01:36 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iExB9-0006NC-AP for xen-devel@lists.xenproject.org; Mon, 30 Sep 2019 15:01:35 +0000 X-Inumbo-ID: 1b30296a-e393-11e9-97fb-bc764e2007e4 Received: from mail-wr1-x441.google.com (unknown [2a00:1450:4864:20::441]) by localhost (Halon) with ESMTPS id 1b30296a-e393-11e9-97fb-bc764e2007e4; Mon, 30 Sep 2019 15:00:57 +0000 (UTC) Received: by mail-wr1-x441.google.com with SMTP id o18so11698925wrv.13 for ; Mon, 30 Sep 2019 08:00:57 -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=DlRmra7nMXyOp1zRJYHjAUTN98YVR6jQ+ZVEzgeJdtg=; b=qtS87TNUBWPDNK/Glrb7l3AQj+UveA3TOaqF7jSdZUp8owi17FbfYw1OiH1t+apfwV fwn3HC4GiO5CfORSSzdP+pigksjhYLMjHsnZ9WVpMSXO6TEXoFVHzENTT11yYvhZl0+Y +0oGlrgcTV7ie/fXLD2/AoB2G/KnkPqC0gg4maEmNl+N11WgWJoJYmM4pLGAZmDlyVNP 6J+XKWUgzbZy3xcwC6NMTYg6Vu8d9hbd3zYLD1/kXwVYJ1Vz0u9CZyOwnUERzq9Z4Sox rEO7GjTW1YFRu9CQjS8Zk1JOVr96RiWl7tlODBLNXcO4/YbwvVWV31UwHOSZqlD7YEMO APjg== 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=DlRmra7nMXyOp1zRJYHjAUTN98YVR6jQ+ZVEzgeJdtg=; b=nk8+CWWYA9KjSxKREdeGgPxFl5YcJZ4Q4SgQ3nT+jXV4cLx/hdOdf0YsI40BiLzRuQ u4rmBTCf4oUKHGAgT4n8vDCsWAULP0MEiIv7fjqqrTbCKVQf8XUcEghJv9q1RzHkYI3s LHqZ2J7clSeI/3LAQho13T7btE2E/jWSMnLyACHi4943S3yQEXfm1ypysAipLlB5l5MU YX5mIjbVSFQNsKgKanBNwIajDy8CFCUg4UdpXmejt/wv3Xv3BOycvTtlKLHmojNaayLO PzlXO5+bIuNMXK687btAcTweKGfGqcKWv396Im02WkJFoXxzkEPTwpXtAtOY7imkZ9SU rjIg== X-Gm-Message-State: APjAAAW8n9i82nLwc/uDqGFWVtNR9HmTz33VAnfnzY9CIN/SbxBJcCKI 3DmpZHLgGAiprAriU/TUXEa6lIRkXvM= X-Google-Smtp-Source: APXvYqznt4+mXcvnxau6YBOyOZ88md4XZ6EwU/yZ321SSukGpRelkLTNyubRmXQ27AFfjNYfgYt7SQ== X-Received: by 2002:a5d:4983:: with SMTP id r3mr14667428wrq.194.1569855656122; Mon, 30 Sep 2019 08:00:56 -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 f143sm32870852wme.40.2019.09.30.08.00.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Sep 2019 08:00:55 -0700 (PDT) From: Wei Liu X-Google-Original-From: Wei Liu To: Xen Development List Date: Mon, 30 Sep 2019 16:00:43 +0100 Message-Id: <20190930150044.5734-10-liuwe@microsoft.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190930150044.5734-1-liuwe@microsoft.com> References: <20190930150044.5734-1-liuwe@microsoft.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH for-next v2 9/9] 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_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" We use the same code structure as we die for Xen. As starters, detect Hyper-V in probe routine. More complex functionalities 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 | 69 ++++++++++++++++++++++++++++++ xen/arch/x86/guest/hypervisor.c | 5 +++ xen/include/asm-x86/guest.h | 1 + xen/include/asm-x86/guest/hyperv.h | 45 +++++++++++++++++++ 7 files changed, 131 insertions(+) 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..4494b87fe8 --- /dev/null +++ b/xen/arch/x86/guest/hyperv/hyperv.c @@ -0,0 +1,69 @@ +/****************************************************************************** + * 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 __init hyperv_probe(void) +{ + uint32_t eax, ebx, ecx, edx; + bool hyperv_guest = false; + + 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) +{ + /* Nothing yet */ +} + +void hyperv_ap_setup(void) +{ + /* Nothing yet */ +} + +void hyperv_resume(void) +{ + /* Nothing yet */ +} + +struct hypervisor_ops hyperv_hypervisor_ops = { + .name = "Hyper-V", + .setup = hyperv_setup, + .ap_setup = hyperv_ap_setup, + .resume = hyperv_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/hypervisor.c b/xen/arch/x86/guest/hypervisor.c index 8161b26c5a..87a195e888 100644 --- a/xen/arch/x86/guest/hypervisor.c +++ b/xen/arch/x86/guest/hypervisor.c @@ -40,6 +40,11 @@ bool hypervisor_probe(void) hops = &xen_hypervisor_ops; #endif +#ifdef CONFIG_HYPERV_GUEST + if ( hyperv_probe() ) + hops = &hyperv_hypervisor_ops; +#endif + 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__ #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..a2d8ee8987 --- /dev/null +++ b/xen/include/asm-x86/guest/hyperv.h @@ -0,0 +1,45 @@ +/****************************************************************************** + * 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 + +extern struct hypervisor_ops hyperv_hypervisor_ops; + +bool hyperv_probe(void); + +#else + +static inline bool hyperv_probe(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: + */