Received: by 10.223.185.116 with SMTP id b49csp6506508wrg; Wed, 28 Feb 2018 10:31:50 -0800 (PST) X-Google-Smtp-Source: AH8x225mtWVeGUYmflG9/2GlRu6OVWRpjkBu1gC56jcgUejTrdiZSHKkHxw/VkqC0mBUCyUTlQir X-Received: by 2002:a17:902:a616:: with SMTP id u22-v6mr18612204plq.211.1519842710589; Wed, 28 Feb 2018 10:31:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519842710; cv=none; d=google.com; s=arc-20160816; b=qhyJK8dge6mBEbUTftRWNSzHcqwMPGhDo8JYvfyTfUuL3SaiMjBYObD4djEJG1uf3k giQ8h/9qAC+iSSp5oZq3OjBh+v7opuWqqUXWHPIv7CCBZ2s/uC+91x+9lmgE5Rfh7YUR MV1gmj8HLlqxZVq/bz787FyWb5g2frAGmYV2FxtWGlxUCnYRo/IwHtSlZgiGTAePV0HW eioGnDGqCcn6HVuSTdaKxJBRpp2RGzJlz7D2tA0QYqyJyz/NyEIwcz4Fs2+gHxNwiNVx BWI1arQ64OP4QaljwG4+6gMc7gdnR8gmgmINk4sDP8bIcNb6G00VAqKohV4Ncaxfd1lV 26mg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=CynUHG06YZdxTsjMWHTTmOcY/puewD1H81xubBboeCo=; b=Tp1tjInr5/0tmsLhCPfKVx60jzxzIMxf/HN7h1Kd+9/RdaxO73EGl0186RskJmj+7n 76XwkN/2KweCgipJv+ceAg9xVFoZMVEgtMqRreAvDa+3uiP6TzD8z+vvsBNcdf9eKTlr tzVKDthEu0LK3o0F6DiM4S0iRFFG1QsAUPJoJvyKoBVITz4q2omLaCKslBLl15G70Nbr wVWRxC7WveJfF69zurJc4h6pgniLNps8u0zHf3ixJtVgtv1/ccgK73IOFEnKttM79vv8 BvX37u1sl0EUU7t69wugIVz7LHGoffM8KQZnaP6ZKZ4HUDATUCRLzb0IhVjcn4BLHnMy Ir2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=h7jVt9ze; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 70si1626714pfk.60.2018.02.28.10.31.33; Wed, 28 Feb 2018 10:31:50 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=h7jVt9ze; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932982AbeB1Sa1 (ORCPT + 99 others); Wed, 28 Feb 2018 13:30:27 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:34788 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932238AbeB1SaY (ORCPT ); Wed, 28 Feb 2018 13:30:24 -0500 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w1SIQYL1138700; Wed, 28 Feb 2018 18:28:47 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2017-10-26; bh=CynUHG06YZdxTsjMWHTTmOcY/puewD1H81xubBboeCo=; b=h7jVt9zeuCU9/AsjOG81HiHQQLTbhgcOx4qb3hpMJsooiJZgYkiGdjb2SWQVd4p0ifD1 1SIsq6IU3XnIah2tBHxUKOzl4IMH0sxUjQ+ftsXDBtA6Rtg4kUNFrY+Mg077PNa+z+3Y YTl83k7GyXaJbv5aBKuKK+GaRRx8FOgqtAFCk/0b8r7ptC5CmGnn6aao4qHTswdEZgKa es2VDhsnhBz+82etLxYPKuUeWJIbUUTOvG1Q5jKzdo/pAOOVh+ZWo/2mTJLzVVVlkNt3 8L5n7PhIkVtGVG31D9dY8FYedmTGAKVVepCipWdMfrMLew6j301M+o77dtXnowvgxMmB Bw== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp2120.oracle.com with ESMTP id 2gdyjqrtaj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 28 Feb 2018 18:28:47 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w1SISkIv004826 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 28 Feb 2018 18:28:46 GMT Received: from abhmp0007.oracle.com (abhmp0007.oracle.com [141.146.116.13]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w1SISjCr012340; Wed, 28 Feb 2018 18:28:45 GMT Received: from marawils-linux.us.oracle.com (/10.141.197.9) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 28 Feb 2018 10:28:44 -0800 From: Maran Wilson To: pbonzini@redhat.com, jgross@suse.com, boris.ostrovsky@oracle.com, roger.pau@citrix.com, andrew.cooper3@citrix.com, hch@infradead.org, JBeulich@suse.com, x86@kernel.org, xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com, rkrcmar@redhat.com, jpoimboe@redhat.com, bp@suse.de, kirill.shutemov@linux.intel.com, thomas.lendacky@amd.com, luto@kernel.org, maran.wilson@oracle.com, dave.hansen@linux.intel.com, davem@davemloft.net, gregkh@linuxfoundation.org, mchehab@kernel.org, linus.walleij@linaro.org, rdunlap@infradead.org Subject: [RFC PATCH v4 4/7] xen/pvh: Move Xen specific PVH VM initialization out of common code Date: Wed, 28 Feb 2018 10:28:00 -0800 Message-Id: <1519842483-8887-5-git-send-email-maran.wilson@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1519842483-8887-1-git-send-email-maran.wilson@oracle.com> References: <1519842483-8887-1-git-send-email-maran.wilson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8818 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1802280224 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We need to refactor PVH entry code so that support for other hypervisors like Qemu/KVM can be added more easily. This patch moves the small block of code used for initializing Xen PVH virtual machines into the Xen specific file. This initialization is not going to be needed for Qemu/KVM guests. Moving it out of the common file is going to allow us to compile kernels in the future without CONFIG_XEN that are still capable of being booted as a Qemu/KVM guest via the PVH entry point. Signed-off-by: Maran Wilson --- arch/x86/pvh.c | 28 ++++++++++++++++++++-------- arch/x86/xen/enlighten_pvh.c | 18 +++++++++++++++++- 2 files changed, 37 insertions(+), 9 deletions(-) diff --git a/arch/x86/pvh.c b/arch/x86/pvh.c index b56cb5e7d6ac..2d7a7f4958cb 100644 --- a/arch/x86/pvh.c +++ b/arch/x86/pvh.c @@ -72,26 +72,38 @@ static void __init init_pvh_bootparams(void) pvh_bootparams.hdr.type_of_loader = (9 << 4) | 0; /* Xen loader */ } +/* + * If we are trying to boot a Xen PVH guest, it is expected that the kernel + * will have been configured to provide the required override for this routine. + */ +void __init __weak xen_pvh_init(void) +{ + xen_raw_printk("Error: Missing xen PVH initialization\n"); + BUG(); +} + +/* + * When we add support for other hypervisors like Qemu/KVM, this routine can + * selectively invoke the appropriate initialization based on guest type. + */ +static void hypervisor_specific_init(void) +{ + xen_pvh_init(); +} + /* * This routine (and those that it might call) should not use * anything that lives in .bss since that segment will be cleared later. */ void __init xen_prepare_pvh(void) { - u32 msr; - u64 pfn; - if (pvh_start_info.magic != XEN_HVM_START_MAGIC_VALUE) { xen_raw_printk("Error: Unexpected magic value (0x%08x)\n", pvh_start_info.magic); BUG(); } - xen_pvh = 1; - - msr = cpuid_ebx(xen_cpuid_base() + 2); - pfn = __pa(hypercall_page); - wrmsr_safe(msr, (u32)pfn, (u32)(pfn >> 32)); + hypervisor_specific_init(); init_pvh_bootparams(); } diff --git a/arch/x86/xen/enlighten_pvh.c b/arch/x86/xen/enlighten_pvh.c index 4b4e9cc78b8a..833c441a20df 100644 --- a/arch/x86/xen/enlighten_pvh.c +++ b/arch/x86/xen/enlighten_pvh.c @@ -1,4 +1,9 @@ -#include +#include + +#include + +#include +#include /* * PVH variables. @@ -9,3 +14,14 @@ */ bool xen_pvh __attribute__((section(".data"))) = 0; +void __init xen_pvh_init(void) +{ + u32 msr; + u64 pfn; + + xen_pvh = 1; + + msr = cpuid_ebx(xen_cpuid_base() + 2); + pfn = __pa(hypercall_page); + wrmsr_safe(msr, (u32)pfn, (u32)(pfn >> 32)); +} -- 2.16.1