Received: by 10.213.65.68 with SMTP id h4csp673737imn; Tue, 20 Mar 2018 12:22:58 -0700 (PDT) X-Google-Smtp-Source: AG47ELsGsRURd66jB6otwe0vL+ioNDfPDfiM/mDB2D20WiwYXR6B2RF+USdbRRNCutxSqNzb8NiR X-Received: by 2002:a17:902:690b:: with SMTP id j11-v6mr17945780plk.124.1521573778436; Tue, 20 Mar 2018 12:22:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521573778; cv=none; d=google.com; s=arc-20160816; b=rGoDy//Ps2xSPaQF3LmeEcNRRoi4w7b7nhhXQYFX+mgDiKdrgdT5Vasg4wrKOdWk0u TuJlMGSLBwaaOXqr6n27ImAmiafHbXs2GYrV6h9gNGBQTkbHrkyDqalO372wjtkSdNQn 5aR5zVIKGCq3dpPBpW0Ka5Z/CqBaUz0lD+jd384qk+fc+Ycta+5JaNHquxqIb2x8h+fL jNYAyqU7CwxgqTP/8HqIcQEG1zUcG8GBxod+so8gf9Jzu0zYm7kId08W7jEuSTzQqFEn RCDjDCgPZQAKONPxTuWKWosMRpsO8TmyL6mvmDAxlsUOY8GDC1ukbuEz1dJfj4+QR9gA nuhQ== 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=82256GxAMesgBbFjVqmIeGU/UBk6Zec2nKWTKX0Ohk4=; b=v9/YB0iIFBsI6ix7lkxZRPDu5qV3Q2NkSdeQAv1Ci6wjVn0DXccUaWMtvhm2HaABva FK/IvCvVQbpnAxGbbGUj41l4LwIgaHLRnhL8aPcVidkTLfEH1pfyhnThpweaGHQS5l9v zwq8JFJ8xk6uIq8moF++H05+TH8MrYuJk9Ydj2r+cre611zQnZI/cLX+TKxhEh/LObgQ ZFJh9C6PexJUospVQHipG2Pe8Ivg3wGZXl+LyjuxoSNeLiqHX7+J72kx7vPOIvTtZGBF YIggHk2SvbAvr4Khm9oJpigp+P/+FxxOwyYmIJVziO7A3E9PhxQcNGaeKAqp3VK07/Du +w8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=qe8XnmZm; 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 e90si483418pfb.156.2018.03.20.12.22.44; Tue, 20 Mar 2018 12:22:58 -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=qe8XnmZm; 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 S1751881AbeCTTVM (ORCPT + 99 others); Tue, 20 Mar 2018 15:21:12 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:59764 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751423AbeCTTUg (ORCPT ); Tue, 20 Mar 2018 15:20:36 -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 w2KJCMfx148344; Tue, 20 Mar 2018 19:20:10 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=82256GxAMesgBbFjVqmIeGU/UBk6Zec2nKWTKX0Ohk4=; b=qe8XnmZmavmR6isrODiat0/JnRSCM1o1PpiZqcfM/BdqhQdO6EE3PwPZdjc1Qu74jgpX IgTVWZoO0apnkUiGXHLZPdYImFmzLbldfvjWOUvqs/00jdZ+RISaL4pp8y3MAPuVAUys g77evSHZUQv8wLLxX/veo3i8DsCCGEqnLC4+wNAHayAJFSHuz13VQVhkwy5kEQEfPN5A R0upcTC6DGa5ZNiQVmYohURjc2ZPdMbKAlnZ1PtRJussrdp8rx9JEv5oLw189ykGEahJ gb1hI4sWadcI41CYrEYIRbw6lFZXcLfzUGpzp3UAz1NdNHe2+Jz3fFEaWGZ8w1ZICLCH Hw== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp2120.oracle.com with ESMTP id 2gu88m0113-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 20 Mar 2018 19:20:10 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w2KJK9Hq016553 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 20 Mar 2018 19:20:09 GMT Received: from abhmp0002.oracle.com (abhmp0002.oracle.com [141.146.116.8]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w2KJK8TJ008571; Tue, 20 Mar 2018 19:20:08 GMT Received: from marawils-linux.us.oracle.com (/10.141.197.9) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 20 Mar 2018 12:20:08 -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 v5 4/7] xen/pvh: Move Xen specific PVH VM initialization out of common file Date: Tue, 20 Mar 2018 12:19:45 -0700 Message-Id: <1521573586-17463-2-git-send-email-maran.wilson@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1521573369-17216-1-git-send-email-maran.wilson@oracle.com> References: <1521573369-17216-1-git-send-email-maran.wilson@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8838 signatures=668695 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-1803200127 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 74c0a711ebe7..b463ee30517a 100644 --- a/arch/x86/platform/pvh/enlighten.c +++ b/arch/x86/platform/pvh/enlighten.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 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