Received: by 10.213.65.68 with SMTP id h4csp1152812imn; Wed, 4 Apr 2018 13:35:47 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+LPvl0sQC6DSgiUzPZvXjYwyMGBjyPT371rd4mblwdgd7nyI5syua6kcY9BFv12FT3ZxHe X-Received: by 10.98.7.83 with SMTP id b80mr15042521pfd.133.1522874147162; Wed, 04 Apr 2018 13:35:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522874147; cv=none; d=google.com; s=arc-20160816; b=y4pY87guRgCP7lxMuP9ycil3RDCt2dRpYffwLD5wI87lKnrGq3AGLT+9ifEPGgdjAt 3S4SUyUworzE5DYlU4x68RdM+/ivOSHM/IDrXj25U1E5Qgfyf4veUlcdJrWDKeMJUXFp ZxIWWugpP0OpqbxYwXVVx35TrsuX71w1t6B/UvBJnK1rfYaod/eedIfMH36ujT9cIRYz B6WlPLo+Y5Al4y3/seSVaJ7pce/drN3WfcG1bXFSeouXEnI/Qf6oGdlKgm3Eb66zPUXW RLkfiue2HAOAL4Ul2R52kHCCLXRRk8hyNxXrB9MyjOrmj5uugD57PzuM2OQ6TlC0AcLl Qwnw== 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=7JIXpJzcqBJT2s69T8+4Ju0Cbjd1VQekxW6mf/7sub8=; b=Xf/VxmQ0bVAh8fmamW84S0eUQT5zcy7/SiUsSYIA3eijeinZRhPLN+/5DoBJs9R4wX MEm+lgxR/O41qHUoroDiv8o6D+xP3Bm3J4YaCrymnG8LpQDnWZKqkOtdVti4MmSL5rxJ 1P9ygfoZ4SkzIkrcKUUSGZpDWpJAORstnykIxXgecyQCknLvUF7/Hi5EFgFyqF0eW7dp F8FJr+mymNw7VCqfU11pWP2jJ5PJoHKMeeVFSeq078v17iZs0sFcjKildxWTc5VGMfz0 tEt8l2eItrwPNP/ltUU+FPgdFhnmkGlj1DNNm3iNGllwqUn6YdJTUVcXuvxj8F82l3bu qQ+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=GXPkCAfA; 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 b3-v6si4087478plr.482.2018.04.04.13.35.33; Wed, 04 Apr 2018 13:35:47 -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=GXPkCAfA; 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 S1752511AbeDDUds (ORCPT + 99 others); Wed, 4 Apr 2018 16:33:48 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:38520 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752234AbeDDUdE (ORCPT ); Wed, 4 Apr 2018 16:33:04 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w34KVb4K095935; Wed, 4 Apr 2018 20:32: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=7JIXpJzcqBJT2s69T8+4Ju0Cbjd1VQekxW6mf/7sub8=; b=GXPkCAfAx4cWR00fBrOY5X91lKT6R8KX+JRbOogmQ2XglpYsIdhVCPXMRkbsCHYnl5DZ /jswE8iECJzGyPIavtqJJeAtwnDseVxjakCyJu9quROUQ77m7Ye1W7E6b7Vwp82pVvVb 8Ju6PisCt2f4XZPL5FhCPmgDJZvD+AzD34JLo/jimYy3jxdXByKppJvIRCGjpU4VlsAe 17CPoyHra6hqB4d5YYDQQkhfqqVEf64KfLQZff9gurLJqtsbYEgEfeKwqE4C2fd+KBZN v+hyiyj0QhYwsz9x22a9M3jXfJ7qaI/JRaenBnRPizzUmf/Szqor2JByqbgghuuLY4ch CA== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp2120.oracle.com with ESMTP id 2h55tt0044-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 04 Apr 2018 20:32:47 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w34KWkDD013219 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 4 Apr 2018 20:32:47 GMT Received: from abhmp0004.oracle.com (abhmp0004.oracle.com [141.146.116.10]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w34KWkdV008479; Wed, 4 Apr 2018 20:32:46 GMT Received: from marawils-linux.us.oracle.com (/10.141.197.9) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 04 Apr 2018 13:32: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 v6 4/7] xen/pvh: Move Xen specific PVH VM initialization out of common file Date: Wed, 4 Apr 2018 13:32:41 -0700 Message-Id: <1522873962-18156-2-git-send-email-maran.wilson@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1522873659-17572-1-git-send-email-maran.wilson@oracle.com> References: <1522873659-17572-1-git-send-email-maran.wilson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8853 signatures=668697 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-1804040198 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 | 18 +++++++++++++++++- 2 files changed, 37 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 c5409c1f259f..08fc63d14ae5 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. @@ -8,3 +13,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