Received: by 10.192.165.156 with SMTP id m28csp1203613imm; Mon, 16 Apr 2018 16:15:23 -0700 (PDT) X-Google-Smtp-Source: AIpwx48LlCjaOLE0eU8WOsn82fkw0F9tqxy78wupWJ3+HXqF8fDNRJ6zv6OK8Z38tEFWdfDQYBsz X-Received: by 2002:a17:902:3e5:: with SMTP id d92-v6mr17661205pld.104.1523920523849; Mon, 16 Apr 2018 16:15:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523920523; cv=none; d=google.com; s=arc-20160816; b=Og/azYVOkJu6wepIoCEzD2R07FCgKsv933NPup2IqHUUBvHQUCx++41HbjXeDVRBId 3VcfoeqI7T0cDjq5g2cxs7dtEQC7LOJIwLY/ficN3mEtzzqmljCV521/QQ5OJLIbbH5G j4A+8ciaq/m9O4hNHZSpQhq/SaeC0bh+PpJfiz1Zn0BqbDKuCoThX59x/yD6c8fyBw5D YbZ8nw8y+4SZyxzbvkGIlrFPmTChHEAQT0AlyaxTrevQvCGQQjUlK0n2rJeyybfGM3yz aIkcsCZ76kxUAM9d8o9Gchot4q+C+vF8OAQ1XVTaTiwmJ2TgAzce8DgL1gfnQQ49b/2y ODvA== 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=NKnolfstzE001j9F6hj5VHb7bjpUShfViXLIe31jhnE=; b=cvaEOBpvjXC/8DT6IHN2I5SreMHGDMscS0UZWxrUGlIM5+290rTfUr90OCSi2g4SXq KLvX3isT5q25ITQGzSk5VhN4+v8bqrYvr6Qostknm9avmDop/UyF3/U5q+jjvKISbkPj UAXgMZLWsMwcOABKi2PmSQvIfQKe5n70r8jh0zfSUsexHKYGuExNBjhwXhhMajBGJ5Lc elZAG2nhxzVYI4sVgJV26c9kJvbOOpqLsSLPp+FuJaW3n3x4hb6AigErCLfoDEbvNVEC qnlj3zbqXv7+UpamxefHyQ2OXInT4rupgduneJlXacUCm5x0DoCVWIdSNIfnyc6R57go Sskw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=b6qFLgri; 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 k137si2792571pgc.493.2018.04.16.16.15.09; Mon, 16 Apr 2018 16:15:23 -0700 (PDT) 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=b6qFLgri; 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 S1753098AbeDPXNb (ORCPT + 99 others); Mon, 16 Apr 2018 19:13:31 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:40380 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751187AbeDPXN3 (ORCPT ); Mon, 16 Apr 2018 19:13:29 -0400 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 w3GNAoXR134176; Mon, 16 Apr 2018 23:12:46 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=NKnolfstzE001j9F6hj5VHb7bjpUShfViXLIe31jhnE=; b=b6qFLgri4U75xIvuGhHmFNtrPwMvBQEnfVLZhhRlAlfAjgYmpgrP1iuZO6kNN4mB+xwc Zwwdcvx+6DH/LE5Rkr58nnE2cXfpXowSVSyoYLgBQo8NlusD+bdR+tscnUbJmr8Iw4L9 W27B7pDw01XMuprPCNtV1fmdP3sN+uMeT/9JbxhgJTsQ/6PKGBkTLVAWDqAV8yDMqMkw QszzaWX+IO7ZlllYOlmgWPMZ/ac7sIEGzBigFLfuLLV3dWQCWIlIiWbYZvACFH/eiXEi 4dIan4w1BqTNyaj2vwwCyTWN9gfRfwwzvXEYtchXzqRRgQenQKMe2cpnaqlkwc5lyS7Y Xg== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp2120.oracle.com with ESMTP id 2hbamnqbb3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 16 Apr 2018 23:12:46 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w3GNCkAG001674 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 16 Apr 2018 23:12:46 GMT Received: from abhmp0007.oracle.com (abhmp0007.oracle.com [141.146.116.13]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w3GNCkHf027307; Mon, 16 Apr 2018 23:12:46 GMT Received: from marawils-linux.us.oracle.com (/10.141.196.252) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 16 Apr 2018 16:12:46 -0700 From: Maran Wilson To: x86@kernel.org, xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, pbonzini@redhat.com, jgross@suse.com Cc: boris.ostrovsky@oracle.com, tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com, roger.pau@citrix.com, rkrcmar@redhat.com, maran.wilson@oracle.com Subject: [PATCH v7 4/7] xen/pvh: Move Xen specific PVH VM initialization out of common file Date: Mon, 16 Apr 2018 16:12:39 -0700 Message-Id: <1523920360-27743-2-git-send-email-maran.wilson@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1523920175-27287-1-git-send-email-maran.wilson@oracle.com> References: <1523920175-27287-1-git-send-email-maran.wilson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8865 signatures=668698 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-1804160192 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 Reviewed-by: Konrad Rzeszutek Wilk Reviewed-by: Juergen Gross --- arch/x86/platform/pvh/enlighten.c | 28 ++++++++++++++++++++-------- arch/x86/xen/enlighten_pvh.c | 20 +++++++++++++++++++- 2 files changed, 39 insertions(+), 9 deletions(-) diff --git a/arch/x86/platform/pvh/enlighten.c b/arch/x86/platform/pvh/enlighten.c index 74ff1c3d2789..edcff7de0529 100644 --- a/arch/x86/platform/pvh/enlighten.c +++ b/arch/x86/platform/pvh/enlighten.c @@ -80,26 +80,38 @@ static void __init init_pvh_bootparams(void) x86_init.acpi.get_root_pointer = pvh_get_root_pointer; } +/* + * 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 313fe499065e..bb5784f354b8 100644 --- a/arch/x86/xen/enlighten_pvh.c +++ b/arch/x86/xen/enlighten_pvh.c @@ -1,4 +1,10 @@ -#include +#include + +#include +#include + +#include +#include /* * PVH variables. @@ -7,3 +13,15 @@ * after startup_{32|64} is invoked, which will clear the .bss segment. */ 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