From patchwork Mon Oct 21 15:57:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Wei Liu X-Patchwork-Id: 11202571 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 06DC313BD for ; Mon, 21 Oct 2019 15:58: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 D6E942084B for ; Mon, 21 Oct 2019 15:58:49 +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="VruVKoyo" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D6E942084B 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 1iMa3l-00089G-Pw; Mon, 21 Oct 2019 15:57:29 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iMa3k-000897-RI for xen-devel@lists.xenproject.org; Mon, 21 Oct 2019 15:57:28 +0000 X-Inumbo-ID: 78843960-f41b-11e9-beca-bc764e2007e4 Received: from mail-wr1-x441.google.com (unknown [2a00:1450:4864:20::441]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 78843960-f41b-11e9-beca-bc764e2007e4; Mon, 21 Oct 2019 15:57:23 +0000 (UTC) Received: by mail-wr1-x441.google.com with SMTP id p4so14608084wrm.8 for ; Mon, 21 Oct 2019 08:57:23 -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=2IQZ0I9t3yp3C2z2Yat7e79RK0J/6Y0pVIEi33A2QSI=; b=VruVKoyoi46WAAHCyYpv0dGzGVF1ZckzzUzsj95IsyeRj1/XGMx307+lSI+hc/7CAU 2CikH0B8lc4LImyaGBxZOdMX/fVfaQQ7VHhrEisWdl1M9AhiCISV1atFai6pVaekYFA2 FGXSTKUVKfwMivjWeD+rbtSaDCm2uj4pSWppIH1ak5dbgORbwAKMFJH3yFSrbcFtDs60 zaliS1LEq4d0BiYhu/txo+b3EeP3ewK6JiB4PJnfaUPO/Le+gsihMUFTozn5dBY67m79 bAFgUWnM3uPZH3V42u4lV/0welJ3E5bwMrfl0Fq7aolaHbOstJGseorIEjT9fKiW21Fb Y5Zg== 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=2IQZ0I9t3yp3C2z2Yat7e79RK0J/6Y0pVIEi33A2QSI=; b=Bzqk7IFqqVIE5vDvgF6tdnzdMY8wer8wEh09crvqgkYF0u9C0zFhxX7ocEKSjnPACx 3y1mMlYnVUDL7kQcELc9khnVfo86YuisXgaiKdMDeadekalKMqfvOxKC1bYjpgXfi2// QhCyK8QvF8/efWqAshxE3WKRzvmBTXqrvlCFW2fWHr8x0UCK2dSJQl+q2AcFYbbai4WL ZuZ8GugJPAkypp5Q4y7bH6zIY/GbsVbkz6WLveFmg31LZQcFXYqq3D3b3b68HrZOwR6g FndcIZvhXOIz0akqoV8oBXgpJMTXvpQt6a+Dl7TYVZRlA1u/8k20aUM5jmnXjm+lnuPy Gp2A== X-Gm-Message-State: APjAAAWUu9G6Q94bI5YuBYz5HxYkAACtWLLaNr0P3UF2bFv0uvet8g7a 1mDUix3YcTWQJa1NW52LVPmtx18K7p8= X-Google-Smtp-Source: APXvYqz/QpnhkeeMScCEg9ZNdUkKmo902bBYBew0ECK1PuASsgxTU2ay2Q+X5j/q5P7jRm1MdJlThg== X-Received: by 2002:adf:f44e:: with SMTP id f14mr10351123wrp.56.1571673442946; Mon, 21 Oct 2019 08:57:22 -0700 (PDT) Received: from debian.mshome.net (54.163.200.146.dyn.plus.net. [146.200.163.54]) by smtp.gmail.com with ESMTPSA id x12sm5667410wru.93.2019.10.21.08.57.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Oct 2019 08:57:22 -0700 (PDT) From: Wei Liu X-Google-Original-From: Wei Liu To: Xen Development List Date: Mon, 21 Oct 2019 16:57:10 +0100 Message-Id: <20191021155718.28653-2-liuwe@microsoft.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191021155718.28653-1-liuwe@microsoft.com> References: <20191021155718.28653-1-liuwe@microsoft.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH for-next v3 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é Acked-by: Jan Beulich --- xen/arch/x86/Kconfig | 4 ++++ xen/arch/x86/Makefile | 2 +- xen/arch/x86/guest/Makefile | 5 +---- xen/arch/x86/guest/xen/Makefile | 4 ++++ xen/arch/x86/guest/{ => 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 28b3b4692a..867de857e8 100644 --- a/xen/arch/x86/Kconfig +++ b/xen/arch/x86/Kconfig @@ -161,8 +161,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 Oct 21 15:57:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Wei Liu X-Patchwork-Id: 11202573 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 C772E1895 for ; Mon, 21 Oct 2019 15:58: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 A37822084B for ; Mon, 21 Oct 2019 15:58: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="RgUlxrsa" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A37822084B 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 1iMa3r-0008AV-3s; Mon, 21 Oct 2019 15:57:35 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iMa3p-0008AE-RV for xen-devel@lists.xenproject.org; Mon, 21 Oct 2019 15:57:33 +0000 X-Inumbo-ID: 78e19b6e-f41b-11e9-beca-bc764e2007e4 Received: from mail-wm1-x341.google.com (unknown [2a00:1450:4864:20::341]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 78e19b6e-f41b-11e9-beca-bc764e2007e4; Mon, 21 Oct 2019 15:57:24 +0000 (UTC) Received: by mail-wm1-x341.google.com with SMTP id q70so6756329wme.1 for ; Mon, 21 Oct 2019 08:57:24 -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=RgUlxrsaouBV1/zOw/oU8WQUPmKTkkz0GSxhjtDrHHKigzUYK/vXkcczo1zgiCYZiq ftKdrABaJSdoEib7Oyw+yeKxS9GBKQLYwJfgTCgEAqJQBH2kIEibUbfWMnpH5c1V0QFc 1YzP7A3K0vTPnCBMVjKjyxsV+GAl4MFcIzTzBSYdXy3Kn6VFuRqH4wgbdpZYGsFEsCiw vdQDXne40Tb5pFeA83OK1DLEPG5VuqR9BUbfBFRONClLep4Bb53UdZLewISt5kPxvJN0 cN79uBTqrTCezFbMWBtT1y690ZkRno/n6JRWTPjtVHMGEGk5xcCgCh7XB/LlvbkKSKMS 6WtA== 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=sPpL1y3Rf4nWsZOogu6qryFjPbc22LFvZQGGgi6YTm6Bg/sdZaIl8nfsf3FoTlSW4d JjJrlkS+KhCjfyInUwVLKII3HrwELWnoMOC/Sks0klt9Xp8Ki2Pk1hBztAQDH7NFazy5 B6vXC2n0am7r3fOhp8UuDNuasY8M4kRGk2K85v36OllmTxSlYDhGZmf3VGMnCKfVvQIT ys98NMBDOIb0szm955gA/xvmG68mqW7CTccfyMQoBQ6y/In5l4gLmNeQ/+7G61VmoKWv kdsI1s8S+zw4qFZdjM+pFm9gt4qIiOztjpUm9RTCkOBWlF3Q9X1umURSbVTFM90mG1BG rCLg== X-Gm-Message-State: APjAAAXB97kKDH5IkJqPtwnO4jyN0B7cN4F325Sa8MKVhOdrr33a8Or6 NXJ3I2Gw2rzwLRl+oJSwYgvoFYFCoq0= X-Google-Smtp-Source: APXvYqzlOafkrkZa7u8z2vDCCyGrxTdYBi4FGl9yCddG0R2z+lZdDw6knnKCDA6wfwvWiLgbkngz4w== X-Received: by 2002:a1c:6885:: with SMTP id d127mr14663510wmc.64.1571673443676; Mon, 21 Oct 2019 08:57:23 -0700 (PDT) Received: from debian.mshome.net (54.163.200.146.dyn.plus.net. [146.200.163.54]) by smtp.gmail.com with ESMTPSA id x12sm5667410wru.93.2019.10.21.08.57.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Oct 2019 08:57:23 -0700 (PDT) From: Wei Liu X-Google-Original-From: Wei Liu To: Xen Development List Date: Mon, 21 Oct 2019 16:57:11 +0100 Message-Id: <20191021155718.28653-3-liuwe@microsoft.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191021155718.28653-1-liuwe@microsoft.com> References: <20191021155718.28653-1-liuwe@microsoft.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH for-next v3 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é Acked-by: Jan Beulich --- 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 Oct 21 15:57:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Wei Liu X-Patchwork-Id: 11202569 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 69C1113BD for ; Mon, 21 Oct 2019 15:58:47 +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 44A022084B for ; Mon, 21 Oct 2019 15:58:47 +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="cOCott3I" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 44A022084B 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 1iMa3w-0008C4-Dz; Mon, 21 Oct 2019 15:57:40 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iMa3u-0008Bp-S9 for xen-devel@lists.xenproject.org; Mon, 21 Oct 2019 15:57:38 +0000 X-Inumbo-ID: 796c0786-f41b-11e9-a531-bc764e2007e4 Received: from mail-wm1-x342.google.com (unknown [2a00:1450:4864:20::342]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 796c0786-f41b-11e9-a531-bc764e2007e4; Mon, 21 Oct 2019 15:57:25 +0000 (UTC) Received: by mail-wm1-x342.google.com with SMTP id g24so4755669wmh.5 for ; Mon, 21 Oct 2019 08:57:25 -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=cOCott3IlMS4VPQuhS1A9bXCgJ36PqouveqzFIX/xALcgYgN2ITLVknLZ6IskZ3A1O yiBDInlLLyUoJ//cZ3Y17Rv6Y/dsgUJBYGGcG5+jH0OsklmFsXHsHJra/aZJmEPuH/Yt 7KsBkyJrorniwucdYZ6jaEX6f8w3ZY/nzKMUERXaYSFK3lbSKNJDvDcdXC6dAlDjNhXL sED7oYncDzZ/kqqkmZRf7Nt536krxYzr25iNpQw7YOVVqgSt0JM0ulMHsxzch2l9sVpQ 7s7EONkXTZ//Az7AVvirNb0bLL52Ntg4Z2X0EcYKrPjYCChBfxvdvlLLAxV+ZumB2oR0 c7Zg== 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=a9dVQjvjQKSvQ+YBbEHD7+PKvLeHynlm3BI5360MqvC3/HssDpqG6/RYZYVq4lhHib OZrXl00KEKlQtKb3YYvkMbxpoE3VpWR1zDddw94VFm5NBKtWTjSlnWOW7QB63ZlOWZYJ 8eZlpemBXRjDefBwBdUThIAuoGS0C8Y9uLZKmmYtyjr6TzFXJxe218FGNERaGq6y3drp mH3aj2ZLU8/yCfo33YZUI7y3hN4WnpmDJ5qud5MZCIAtH0UY6vmkSGNC4w//ZiawPSDB qPVUPT/y2815HIH0EVxFaWuDz2tx0D5wuV7PeXlIGWPSskbMbmHwXqSvgBO+w9gyFaa3 eNRQ== X-Gm-Message-State: APjAAAUAdDWRHGTeYTcCvLE89lq8SLztkDyRdVzc3lzjrEO+OJcxaU9/ YdCMPAQ52x24nC6USq7Vh9pFdoMu7EU= X-Google-Smtp-Source: APXvYqzz/Kta5VBd7jInxuR3R8kaAQZgp7VU60sA8hcqypb8SutSv4zTfLJHuzmPKcpvp74dnssEqA== X-Received: by 2002:a7b:cb54:: with SMTP id v20mr18859985wmj.119.1571673444539; Mon, 21 Oct 2019 08:57:24 -0700 (PDT) Received: from debian.mshome.net (54.163.200.146.dyn.plus.net. [146.200.163.54]) by smtp.gmail.com with ESMTPSA id x12sm5667410wru.93.2019.10.21.08.57.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Oct 2019 08:57:24 -0700 (PDT) From: Wei Liu X-Google-Original-From: Wei Liu To: Xen Development List Date: Mon, 21 Oct 2019 16:57:12 +0100 Message-Id: <20191021155718.28653-4-liuwe@microsoft.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191021155718.28653-1-liuwe@microsoft.com> References: <20191021155718.28653-1-liuwe@microsoft.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH for-next v3 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é Acked-by: Jan Beulich --- xen/arch/x86/guest/xen/xen.c | 7 +------ xen/arch/x86/pv/shim.c | 2 +- xen/include/asm-x86/guest/xen.h | 2 +- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/xen/arch/x86/guest/xen/xen.c b/xen/arch/x86/guest/xen/xen.c index 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 Oct 21 15:57:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Wei Liu X-Patchwork-Id: 11202577 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 95FC513BD for ; Mon, 21 Oct 2019 15:58:53 +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 71F4E2084B for ; Mon, 21 Oct 2019 15:58:53 +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="el+It4Bi" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 71F4E2084B 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 1iMa41-0008EX-Sy; Mon, 21 Oct 2019 15:57:45 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iMa3z-0008Dt-SO for xen-devel@lists.xenproject.org; Mon, 21 Oct 2019 15:57:43 +0000 X-Inumbo-ID: 79d23934-f41b-11e9-bbab-bc764e2007e4 Received: from mail-wr1-x443.google.com (unknown [2a00:1450:4864:20::443]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 79d23934-f41b-11e9-bbab-bc764e2007e4; Mon, 21 Oct 2019 15:57:26 +0000 (UTC) Received: by mail-wr1-x443.google.com with SMTP id v9so3356474wrq.5 for ; Mon, 21 Oct 2019 08:57:26 -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=N4kqMtXKr2VI6xhju+2HY7aOkc8zfZUqqp0CH2GZ8kc=; b=el+It4BiEwx+dhiQlehX+3tMT8XfCZVwMtJvjBchGJzOm4dGe57t7lpbF3YzixAzL8 gGadBC/BZOiH8wP2UizfpkDMzMCjL40fwkObRQCE3zdyaalTDwUmQzeQXKxk6QKkTiPZ S+73WKEtn7S0TJewHf6Ge/uLHGcTPxLIwQ8zf65UrbOdrihZy6Mzj4CDO6Rt0vT0SrBD hdTWoyp0vgloXY7XKQRhyp7fM4TBy8E5Hhompnr+xsuThTIk9ZvB5czQNCzE7q8H+WHO BAp0e/+y7ISgxxM7ZlICw0NGOT3hsmbyEquzHEIGEAc6042KL4XSgllPLtY7iL/yOWo+ DD9g== 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=N4kqMtXKr2VI6xhju+2HY7aOkc8zfZUqqp0CH2GZ8kc=; b=r9DSfa8a5L9NPb5hnmJpqhFUZVZCOWscnooFBq8XHBz7viOheR9WmK/yXTM7cMZtO2 kXfm/i232wAxgcYPSkAZL5WX5/P1jfemBUrCdV06hS9lWCwz1iZDsOAmxOjzECtiZiOA PjZk2ZuHHjCfAIT9JmJUEP0qqutv3cMorps1vP1vqkwgGnQsJW0SFMbf2VMYUsOFNH66 eXcONVCekGJnzdi936Q9Imk2bomZIgxffAqyzf/rPMvNwHpynbw3lKwJs4bgiKHHrF00 7LXSh58HyLjLuoLcvJeFx2cuCQ9ryEq17psAragOoE+KEOCDB8Hp/wONFOA6L5flKl7v D7gw== X-Gm-Message-State: APjAAAUQDQwgM6uBSI0u+Ap0RKQPhuDxrC5Kmse6EOKtezZRh+FdpmXc annqH6436HdlREsyYqETW87yPiamm8U= X-Google-Smtp-Source: APXvYqzwrIPVWBtBGwvNDvcP+QiFfxITf+dHZITn8MCV8YvrsbPHAGKXjlux5EHhW5YqOJTKhLjTLA== X-Received: by 2002:a5d:6447:: with SMTP id d7mr12892447wrw.247.1571673445284; Mon, 21 Oct 2019 08:57:25 -0700 (PDT) Received: from debian.mshome.net (54.163.200.146.dyn.plus.net. [146.200.163.54]) by smtp.gmail.com with ESMTPSA id x12sm5667410wru.93.2019.10.21.08.57.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Oct 2019 08:57:24 -0700 (PDT) From: Wei Liu X-Google-Original-From: Wei Liu To: Xen Development List Date: Mon, 21 Oct 2019 16:57:13 +0100 Message-Id: <20191021155718.28653-5-liuwe@microsoft.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191021155718.28653-1-liuwe@microsoft.com> References: <20191021155718.28653-1-liuwe@microsoft.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH for-next v3 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é Acked-by: Jan Beulich --- 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 Oct 21 15:57:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Liu X-Patchwork-Id: 11202579 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 48A731895 for ; Mon, 21 Oct 2019 15:59: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 2503720B7C for ; Mon, 21 Oct 2019 15:59: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="EWw8ev4X" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2503720B7C 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 1iMa46-0008GB-71; Mon, 21 Oct 2019 15:57:50 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iMa44-0008Fq-Sv for xen-devel@lists.xenproject.org; Mon, 21 Oct 2019 15:57:48 +0000 X-Inumbo-ID: 7a616f1e-f41b-11e9-bbab-bc764e2007e4 Received: from mail-wm1-x341.google.com (unknown [2a00:1450:4864:20::341]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 7a616f1e-f41b-11e9-bbab-bc764e2007e4; Mon, 21 Oct 2019 15:57:27 +0000 (UTC) Received: by mail-wm1-x341.google.com with SMTP id c22so4239747wmd.1 for ; Mon, 21 Oct 2019 08:57:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=jBrEUmLmtAmRmL0ZQe75O+VGK/lIBJ2eQ4PSZ4jPdH0=; b=EWw8ev4XbD5uXEbn9iAQyd79L3Ub3XQoA5XpmnAjHIi+p9yTY1qcYqgdbn4GuCwPKM Rlj59AsjeQkjg00V1xO4ftnx3kHRwVK7VzxVt2Z8n3RwgEwTa8Nwhw61i6Zr3N9wY8Te pZRJb5uvfKGtLhHMiEKM5RZd+dUZXSo6s3fuecIGR4zH3YDy7SP6QqHTs2cHDYfxN7dY S1fSMXGeHmmBBmDjE91bIX+R99nbh8xkDdmp2bkb3WPqw0SVNhDsQjvsCHEh0dHMduJ7 H0TrKGkcdRJ4yv+mYOzN3YN2nG234Y0RSM09557Xnkg7VZrZJULvTmLetIWIxAor1pjv aGNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=jBrEUmLmtAmRmL0ZQe75O+VGK/lIBJ2eQ4PSZ4jPdH0=; b=M3IWEdkZQysJcPBKWUOKSgAvMUnJ68NyYIKLdfm2ap0D6poYWD0jHKzfZZgMg16Dx5 fM6nPFyKrGRd8QXZRZkigGGR+dTm3LzhI/MFTqnYb4T2FN4I6DuaFp9OXwo725zbXBuo eTCm5AaoVlZaoTcHbCGkJTPYBHkuQ5HJ172WZ+KDkWRWCJqiuZlQAUS4MtEpTU/0cG3e /NYF6Sx4PVSJQLI6WuKn2d8SOkYSgrX8JRmfccQVGp/AT1GUt/yqtynMALmYTpmjUfQq HD+z8J5SBU29WCkFwo7w2gNp3D6KVvy+QbB+Kt3kX0RWXXBal0LtcSUFtcrrLZUWusEa EWIA== X-Gm-Message-State: APjAAAWsUdrXRXqYLNIBgoST8qCD6RpyMBGEFzQvimWb+FggVRbiuunu fLgbJaAAqY5WHbjTMq9XBPGESGedAgI= X-Google-Smtp-Source: APXvYqyO/sJRzgkxKMuVKoWxsxZIEOo3Odlp+bUvQrXRafR6MoUmi6fT+irY1y0FjDTvsdfQs7drpw== X-Received: by 2002:a1c:38c3:: with SMTP id f186mr4252455wma.58.1571673445980; Mon, 21 Oct 2019 08:57:25 -0700 (PDT) Received: from debian.mshome.net (54.163.200.146.dyn.plus.net. [146.200.163.54]) by smtp.gmail.com with ESMTPSA id x12sm5667410wru.93.2019.10.21.08.57.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Oct 2019 08:57:25 -0700 (PDT) From: Wei Liu X-Google-Original-From: Wei Liu To: Xen Development List Date: Mon, 21 Oct 2019 16:57:14 +0100 Message-Id: <20191021155718.28653-6-liuwe@microsoft.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191021155718.28653-1-liuwe@microsoft.com> References: <20191021155718.28653-1-liuwe@microsoft.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH for-next v3 5/9] x86: introduce hypervisor framework X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Wei Liu , Wei Liu , Andrew Cooper , Michael Kelley , Jan Beulich , =?utf-8?q?Roger_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 Reviewed-by: Paul Durrant --- xen/arch/x86/guest/Makefile | 2 + xen/arch/x86/guest/hypervisor.c | 45 +++++++++++++++++++ xen/include/asm-x86/guest.h | 1 + xen/include/asm-x86/guest/hypervisor.h | 61 ++++++++++++++++++++++++++ xen/include/asm-x86/guest/xen.h | 12 ----- 5 files changed, 109 insertions(+), 12 deletions(-) create mode 100644 xen/arch/x86/guest/hypervisor.c create mode 100644 xen/include/asm-x86/guest/hypervisor.h diff --git a/xen/arch/x86/guest/Makefile b/xen/arch/x86/guest/Makefile index 6806f04947..f63d64bbee 100644 --- a/xen/arch/x86/guest/Makefile +++ b/xen/arch/x86/guest/Makefile @@ -1 +1,3 @@ +obj-y += 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 Oct 21 15:57:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Wei Liu X-Patchwork-Id: 11202581 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 594431895 for ; Mon, 21 Oct 2019 15:59:05 +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 350C82084B for ; Mon, 21 Oct 2019 15:59:05 +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="MDrHd9/w" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 350C82084B 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 1iMa4B-0008IS-HW; Mon, 21 Oct 2019 15:57: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 1iMa49-0008Hl-SJ for xen-devel@lists.xenproject.org; Mon, 21 Oct 2019 15:57:53 +0000 X-Inumbo-ID: 7b1566c2-f41b-11e9-beca-bc764e2007e4 Received: from mail-wm1-x343.google.com (unknown [2a00:1450:4864:20::343]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 7b1566c2-f41b-11e9-beca-bc764e2007e4; Mon, 21 Oct 2019 15:57:28 +0000 (UTC) Received: by mail-wm1-x343.google.com with SMTP id c22so4239809wmd.1 for ; Mon, 21 Oct 2019 08:57:28 -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=ExfOi0N6VUGqchtp2Vv94a4Sc6kPF7iWTxBmQdbZTUY=; b=MDrHd9/w6r2SS5bNBvH4wPUa25y5FsK6mLR8DbHPxvWHD+2naAhHzESjYDv1pIsGo/ geOo0flBHGontoIoY1lHkZRXiLdDAntbGI9XRkcb1Q8PQhIE/uAl4nTHzlGSAd0+Eb2Z YQ3RIqMeJvXiArZVWfSVmTYMrfCNfLw9y2gfwQoxuCUjOv/Ed62jnZip/r+SB1PxRwFC rg5bYShShrXt/NS/ds7wPnZmU47Sm84Jy0BdBf5NSD7wptgFzDfJ+kprnX9hokCJLbY6 mOKvOqs389qxDGFg1jkkd4usU64HUgQqchEzNcLevI8G636jgoyn6FWb1U5XkqP/stTJ X0cQ== 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=ExfOi0N6VUGqchtp2Vv94a4Sc6kPF7iWTxBmQdbZTUY=; b=F5rN1vbyQ7+dd4rKnVFoKeuy6RiJs9d9JBNYwnnXGyCe1w2/ETykPqn8iIQVxkD8vH fOEZHTNBtsvYtVB+IPiQ9bkSQ74ETAUbv4X9XGTLWDmx9gadqwdWIh3Sp6unahNYFhNg k4YnRPH0j3mGS1ExdDKTl7FWcc/JLEwecLR+L8890NZcOPdPNcsRyRQ55Eh+bfqyr1vv 570cNpVOHRscA+vHf7vfGOq2M1f9XUFHu1zvJFucVp2e70C5+qMxLscV7tg1TI1+FUdu Hgfg1vnfH6vlLifoVlqJroB5wna9F8734T/6nt+zouaa+GUcB5UkL3On4fxFDto9pQjE DnSw== X-Gm-Message-State: APjAAAXBxR1l0ixi8u43T6QWrIUrB3CcF5Qhpa+OIpRQytPCneZzXEic qd4mq/A2I6sHAdkMFrekddXhNxj5HQU= X-Google-Smtp-Source: APXvYqxwIHsOQ9QEmy2XrZYBQQSBlbkiyNYA8Sza8Uiz/Qc+g6OpkO99Vrybf2mgWPoMjr5yFxH0aQ== X-Received: by 2002:a7b:c5c9:: with SMTP id n9mr21037600wmk.28.1571673447173; Mon, 21 Oct 2019 08:57:27 -0700 (PDT) Received: from debian.mshome.net (54.163.200.146.dyn.plus.net. [146.200.163.54]) by smtp.gmail.com with ESMTPSA id x12sm5667410wru.93.2019.10.21.08.57.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Oct 2019 08:57:26 -0700 (PDT) From: Wei Liu X-Google-Original-From: Wei Liu To: Xen Development List Date: Mon, 21 Oct 2019 16:57:15 +0100 Message-Id: <20191021155718.28653-7-liuwe@microsoft.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191021155718.28653-1-liuwe@microsoft.com> References: <20191021155718.28653-1-liuwe@microsoft.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH for-next v3 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 Oct 21 15:57:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Liu X-Patchwork-Id: 11202583 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 7995013BD for ; Mon, 21 Oct 2019 15:59:08 +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 556752084B for ; Mon, 21 Oct 2019 15:59:08 +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="RpYQA9UT" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 556752084B 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 1iMa4G-0008M6-Rw; Mon, 21 Oct 2019 15:58:00 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iMa4E-0008Kx-Sc for xen-devel@lists.xenproject.org; Mon, 21 Oct 2019 15:57:58 +0000 X-Inumbo-ID: 7b970542-f41b-11e9-bbab-bc764e2007e4 Received: from mail-wm1-x341.google.com (unknown [2a00:1450:4864:20::341]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 7b970542-f41b-11e9-bbab-bc764e2007e4; Mon, 21 Oct 2019 15:57:29 +0000 (UTC) Received: by mail-wm1-x341.google.com with SMTP id f22so13350541wmc.2 for ; Mon, 21 Oct 2019 08:57:29 -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=uz0cS8L1R521fTEVFm/na4uChFFZ0A6x5sP6HVSJ75Y=; b=RpYQA9UTZA3W/Fwz6T+Ti1SufM8dwZLv3CQz4+1q0tT0Je3aWk4yrmQyAKYOqw5rpz e1cbfcVBK4BP7ADh/HbgIRaF16e15L6o4tM1z11xF2Lhx0Pif73lZA1KbLRSanOifRSG T8PJSn4erosWoMqoQCXtt6ph1fxCvm8WXr3bQk01cXquEtuwu0v3VIvb7J249RiPxAw0 H/6/jPE/hgrdHBJLPGOGr9l9We5HdrKYbdyntQuRsUtka42gvlAMfTuEPB5/NR4D8Cjc wl8uUGCJK1gpgOoY2vxYkS1tNOtxyKsLlF/gmofBjPH2U8Rb7CGDURCdKkZ9/ziIeCRh OS1Q== 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=uz0cS8L1R521fTEVFm/na4uChFFZ0A6x5sP6HVSJ75Y=; b=atxhQHj84L4nrLKLhvovjqovyaUV6Xhc+lqoEXIJzutcgaqs4M4vciYCpdVvdSKhD3 O2DCpyGCjGOf6P32Lf6CWIKM7+JTF9GyCMPEesTBfS0yUZi+CE09Ml4GQq+GNReIEwx2 55gFjBxEyqDHL3McclubNk83EeN5F8ww+OE9E6Ydp9rZHaVgQ2P19n07pxYBI270j54t uv0AweW2oHF/l5VCWvvsN3biMrjckvsn7ZX/EcjNA8mBPeO8vXgwPVl8zvpyND8bwHSs S2k/JCIho/7xz8n2xa/9znv0nzzm41kBq1YsT7za+9pn18aFIJy5q8AuTRLkKk7zcPY+ JOLA== X-Gm-Message-State: APjAAAWSFhEU2wGmiyJZZqje10sfJm5WSgPj5r4nffitv5ifIbFP9NjU JdEtwRcIprNKFacBtCCEpx6GVGBO+FU= X-Google-Smtp-Source: APXvYqxl/DJi3lmFlYPpP/hatAwpG7yl3D+pn563UVteuV6a/m3MEG3ZuxYSWnxyh0y0HFEqN4Kjiw== X-Received: by 2002:a1c:a78b:: with SMTP id q133mr7388392wme.115.1571673448058; Mon, 21 Oct 2019 08:57:28 -0700 (PDT) Received: from debian.mshome.net (54.163.200.146.dyn.plus.net. [146.200.163.54]) by smtp.gmail.com with ESMTPSA id x12sm5667410wru.93.2019.10.21.08.57.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Oct 2019 08:57:27 -0700 (PDT) From: Wei Liu X-Google-Original-From: Wei Liu To: Xen Development List Date: Mon, 21 Oct 2019 16:57:16 +0100 Message-Id: <20191021155718.28653-8-liuwe@microsoft.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191021155718.28653-1-liuwe@microsoft.com> References: <20191021155718.28653-1-liuwe@microsoft.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH for-next v3 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 Reviewed-by: Paul Durrant Acked-by: Jan Beulich --- V3: 1. Address Roger's comments 2. Change xen_hypervisor_ops to xen_ops --- xen/arch/x86/guest/hypervisor.c | 32 ++++++++++++++++++++++++++++++- 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, 51 insertions(+), 17 deletions(-) diff --git a/xen/arch/x86/guest/hypervisor.c b/xen/arch/x86/guest/hypervisor.c index 89b9ae4de0..33bf1a769d 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,9 +31,39 @@ bool hypervisor_probe(void) if ( hops ) return true; + /* 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_ops; + return true; + } +#endif + return false; } +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(); +} + /* * Local variables: * mode: C diff --git a/xen/arch/x86/guest/xen/pvh-boot.c b/xen/arch/x86/guest/xen/pvh-boot.c index ca8e156f7d..498625eae0 100644 --- a/xen/arch/x86/guest/xen/pvh-boot.c +++ b/xen/arch/x86/guest/xen/pvh-boot.c @@ -103,7 +103,7 @@ void __init pvh_init(multiboot_info_t **mbi, module_t **mod) { convert_pvh_info(mbi, mod); - 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..655435c1f7 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) +static void __init xen_setup(void) { init_memmap(); @@ -277,7 +272,7 @@ void __init hypervisor_setup(void) init_evtchn(); } -void hypervisor_ap_setup(void) +static 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) +static 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_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..c3c6bea24f 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_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 Oct 21 15:57:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Liu X-Patchwork-Id: 11202585 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 29DDF13BD for ; Mon, 21 Oct 2019 15:59: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 059FD20B7C for ; Mon, 21 Oct 2019 15:59: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="MUKAOFhl" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 059FD20B7C 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 1iMa4L-0008Oj-5x; Mon, 21 Oct 2019 15:58: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 1iMa4J-0008O2-Sr for xen-devel@lists.xenproject.org; Mon, 21 Oct 2019 15:58:03 +0000 X-Inumbo-ID: 7c1217e6-f41b-11e9-beca-bc764e2007e4 Received: from mail-wm1-x344.google.com (unknown [2a00:1450:4864:20::344]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 7c1217e6-f41b-11e9-beca-bc764e2007e4; Mon, 21 Oct 2019 15:57:29 +0000 (UTC) Received: by mail-wm1-x344.google.com with SMTP id q70so6756663wme.1 for ; Mon, 21 Oct 2019 08:57:29 -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=f6in2kwAF9sUzg2Mb4eb4h7EVvG820SHOVnsWYNNk9o=; b=MUKAOFhlOV0lipkA3Qj18xiI6jhWf6fmWwWPwtnJAQzlhbmMRVzmaR0NXuyaM3yipW HOsi01QexFr6Q83AJHRNVrlChT1Fkk93sxOhWiXsmIL0f2ZKitcm/73nC0K+NLF7+k+p XNxgHpVNeerACM3motyD2xj5Ms89+puPCEb2bdG6WgiGKIzc5rFhdWxBa3PN+kEilxYA WzsXBSzxopWNanWlRO2dko8eQQTxn9xuGvBCMKwGk+5bsz+u6zQg0uZ+HTo6KuMzjuzm ktJtP/45Vu4dlEIb3prsn0fYjtMlgX+2cvUvn71CAnSls/Qm/rvTx2TZg0+qttjsc3T/ X6zA== 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=f6in2kwAF9sUzg2Mb4eb4h7EVvG820SHOVnsWYNNk9o=; b=JLlFyr3Dz2RFt6k38GPzWRohTurEEMUZ1l1msd8nblRlcKUL3/PJlL5q+TZvcOcYvD lGsm+agTAYdpJOmW5GWwf8mK7ND09dbnQipM58iLZdV7Yv0tfc7R091QQ9D3Rqssx8ZS H0VlUVWbi8Q4rp3d7ejytwlrz4QRL0O5eSvxhs1PpJ6GSQP8cER8iqePNmhhTna3JiWF N5GziDXe/xaz1ymzb1rFveiz2PHblHv4Sx1xPiEDYPsC3wDx1ASnPFhzAaRAzwumpD8T 9ugjtnyWvk2W3qIJvuroVl8QTNa9ieYF2+ENnni7mqxNX3Slsrc1d9w8s/6VMf/uEVjL 4Jxg== X-Gm-Message-State: APjAAAVkvrQYG+Sfrj7CHEhElg4Xab4+Nhst3KM/jr3A/WNRmG1GLivz Vr3FNhYo1eWdSqdcEfVi7S5QtbkWzHA= X-Google-Smtp-Source: APXvYqxHE3iK/0W6DtLJyb6xZXf4NNJOheJkAeLWWTme7Y7mktHsl4XmDpU67XhLM0PcvmGGFT/xtQ== X-Received: by 2002:a7b:c444:: with SMTP id l4mr19445804wmi.21.1571673448928; Mon, 21 Oct 2019 08:57:28 -0700 (PDT) Received: from debian.mshome.net (54.163.200.146.dyn.plus.net. [146.200.163.54]) by smtp.gmail.com with ESMTPSA id x12sm5667410wru.93.2019.10.21.08.57.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Oct 2019 08:57:28 -0700 (PDT) From: Wei Liu X-Google-Original-From: Wei Liu To: Xen Development List Date: Mon, 21 Oct 2019 16:57:17 +0100 Message-Id: <20191021155718.28653-9-liuwe@microsoft.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191021155718.28653-1-liuwe@microsoft.com> References: <20191021155718.28653-1-liuwe@microsoft.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH for-next v3 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 Reviewed-by: Paul Durrant --- V3: Address Roger's comment, add ASSERTs --- xen/arch/x86/guest/hypervisor.c | 6 ++++++ xen/arch/x86/setup.c | 6 +++++- xen/include/asm-x86/guest/hypervisor.h | 3 +++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/xen/arch/x86/guest/hypervisor.c b/xen/arch/x86/guest/hypervisor.c index 33bf1a769d..a666ad9526 100644 --- a/xen/arch/x86/guest/hypervisor.c +++ b/xen/arch/x86/guest/hypervisor.c @@ -46,6 +46,12 @@ bool hypervisor_probe(void) return false; } +const char *hypervisor_name(void) +{ + ASSERT(hops); + return hops->name; +} + void hypervisor_setup(void) { if ( hops && hops->setup ) diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 0ee11b15a6..cf5a7b8e1e 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -689,6 +689,7 @@ void __init noreturn __start_xen(unsigned long mbi_p) int i, j, e820_warn = 0, bytes = 0; bool acpi_boot_table_init_done = false, relocated = false; int ret; + bool running_on_hypervisor; struct ns16550_defaults ns16550 = { .data_bits = 8, .parity = 'n', @@ -763,7 +764,7 @@ void __init noreturn __start_xen(unsigned long mbi_p) * allocing any xenheap structures wanted in lower memory. */ kexec_early_calculations(); - hypervisor_probe(); + running_on_hypervisor = hypervisor_probe(); parse_video_info(); @@ -789,6 +790,9 @@ void __init noreturn __start_xen(unsigned long mbi_p) printk("Xen image load base address: %#lx\n", xen_phys_start); + if ( running_on_hypervisor ) + printk("Running on %s\n", hypervisor_name()); + #ifdef CONFIG_VIDEO printk("Video information:\n"); diff --git a/xen/include/asm-x86/guest/hypervisor.h b/xen/include/asm-x86/guest/hypervisor.h index 38344e2e89..b583722f5d 100644 --- a/xen/include/asm-x86/guest/hypervisor.h +++ b/xen/include/asm-x86/guest/hypervisor.h @@ -36,15 +36,18 @@ bool hypervisor_probe(void); void hypervisor_setup(void); void hypervisor_ap_setup(void); void hypervisor_resume(void); +const char *hypervisor_name(void); #else +#include #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) {} +static inline char *hypervisor_name(void) { ASSERT_UNREACHABLE(); return NULL; } #endif /* CONFIG_GUEST */ From patchwork Mon Oct 21 15:57:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Liu X-Patchwork-Id: 11202587 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 EC6CA1895 for ; Mon, 21 Oct 2019 15:59:22 +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 C7A9A20B7C for ; Mon, 21 Oct 2019 15:59:22 +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="D99cQRcq" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C7A9A20B7C 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 1iMa4P-0008Sb-MP; Mon, 21 Oct 2019 15:58:09 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iMa4O-0008S0-TW for xen-devel@lists.xenproject.org; Mon, 21 Oct 2019 15:58:08 +0000 X-Inumbo-ID: 7c946b7e-f41b-11e9-beca-bc764e2007e4 Received: from mail-wm1-x343.google.com (unknown [2a00:1450:4864:20::343]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 7c946b7e-f41b-11e9-beca-bc764e2007e4; Mon, 21 Oct 2019 15:57:30 +0000 (UTC) Received: by mail-wm1-x343.google.com with SMTP id q13so3884654wmj.0 for ; Mon, 21 Oct 2019 08:57:30 -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=+9p0XoTnmWEXGbOkz/xPFNftw6o4q7PdA5mk2bpDbeo=; b=D99cQRcqnw8U2NSMpL3xgc3ED+ucuVjXTA8M/tyYbXW5S3WPrjhy3jUsnFiuFXowl8 Po0nnRoydLrfHnUEz3RXBz1vWj6CQjzmruUcxgYxggBWHCJl2bMGoLWXksIhSv0QH2KU MMOitG4ozrCQsN5226ODtMVHYJXTJH0REF39wfqE5J4bN3iJDzW31XUrrlJLZtwIwlq6 aBI24yWUE7QcITfFt3pLTTiElpuUR7Lrxks1ihOqeQXuIkqh8dTF1gmaukasx0eyU6VL 4A26xIcBne6MKGGA7LiiW6QBdLyXYza7CMhUDTHFLwDlTdX/zedH0xEn0A5gtxBCA6yE Rqiw== 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=+9p0XoTnmWEXGbOkz/xPFNftw6o4q7PdA5mk2bpDbeo=; b=pmjBprflwXZTCV4EA2MKxuWtHriZXURSN99Vm7UPKW5wJxaFqjpfwRdUuQ7w20JjVe 1E/ykO7SBDlz65uQcwY6aX3AxDwRbvcftDzLk49sRccROHcPFTgSgHj2QbKV9nq/A9Rg 7XBE9WD4emgFrsXedhNjQrfH5PfoCN3MqsQsXOXtDYKpMz2PBWs1YrAZuJlyfwrnlJxE gnUSFxXydju/6a6rcP5UBn7DcQCOvd0/jPE5Grr+jk2LMKdfZpWG6tsUu5AhvfwEuG4W VKDo43eVXc1K/E0aT+x49X5LtGva6ZblU2CnpzUbKNXDv2zsYitP1lMh6JOpkSxsUG1w hSVA== X-Gm-Message-State: APjAAAV+oVoNAzF6nAyHwFN+flJ0Hs2YqlGoEnhuuZbQA0Z1oziNqfKt d2owfI3MOvEkgt5zqED499g2v6F/x9A= X-Google-Smtp-Source: APXvYqxhbk/dKoNrV6v0Hv+TOIEoYaVGGEN1wftjCpczrGkIH8vWwuv/76XWVwiggV4bRtf1rnig/w== X-Received: by 2002:a05:600c:253:: with SMTP id 19mr18525827wmj.158.1571673449699; Mon, 21 Oct 2019 08:57:29 -0700 (PDT) Received: from debian.mshome.net (54.163.200.146.dyn.plus.net. [146.200.163.54]) by smtp.gmail.com with ESMTPSA id x12sm5667410wru.93.2019.10.21.08.57.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Oct 2019 08:57:29 -0700 (PDT) From: Wei Liu X-Google-Original-From: Wei Liu To: Xen Development List Date: Mon, 21 Oct 2019 16:57:18 +0100 Message-Id: <20191021155718.28653-10-liuwe@microsoft.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191021155718.28653-1-liuwe@microsoft.com> References: <20191021155718.28653-1-liuwe@microsoft.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH for-next v3 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 did for Xen. As starters, detect Hyper-V in probe routine. More complex functionalities will be added later. Signed-off-by: Wei Liu Reviewed-by: Paul Durrant --- V3: 1. Remove some unused code 2. Rename structure 3. Also detect HV#1 signature --- 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 | 54 ++++++++++++++++++++++++++++++ xen/arch/x86/guest/hypervisor.c | 8 +++++ xen/include/asm-x86/guest.h | 1 + xen/include/asm-x86/guest/hyperv.h | 45 +++++++++++++++++++++++++ 7 files changed, 119 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 867de857e8..56513c771c 100644 --- a/xen/arch/x86/Kconfig +++ b/xen/arch/x86/Kconfig @@ -164,6 +164,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..7ab4b127f3 --- /dev/null +++ b/xen/arch/x86/guest/hyperv/hyperv.c @@ -0,0 +1,54 @@ +/****************************************************************************** + * arch/x86/guest/hyperv/hyperv.c + * + * Support for detecting and running under Hyper-V. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; If not, see . + * + * Copyright (c) 2019 Microsoft. + */ +#include + +#include + +bool __init hyperv_probe(void) +{ + uint32_t eax, ebx, ecx, edx; + + cpuid(0x40000000, &eax, &ebx, &ecx, &edx); + if ( !((ebx == 0x7263694d) && /* "Micr" */ + (ecx == 0x666f736f) && /* "osof" */ + (edx == 0x76482074)) ) /* "t Hv" */ + return false; + + cpuid(0x40000001, &eax, &ebx, &ecx, &edx); + if ( eax != 0x31237648 ) /* Hv#1 */ + return false; + + return true; +} + +struct hypervisor_ops hyperv_ops = { + .name = "Hyper-V", +}; + +/* + * 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 a666ad9526..17392d1ffa 100644 --- a/xen/arch/x86/guest/hypervisor.c +++ b/xen/arch/x86/guest/hypervisor.c @@ -43,6 +43,14 @@ bool hypervisor_probe(void) } #endif +#ifdef CONFIG_HYPERV_GUEST + if ( hyperv_probe() ) + { + hops = &hyperv_ops; + return true; + } +#endif + return false; } 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..4b9cc5a836 --- /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_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: + */