From patchwork Thu Feb 6 15:20:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 11368811 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 E9CF9109A for ; Thu, 6 Feb 2020 15:21:19 +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 D0C7520838 for ; Thu, 6 Feb 2020 15:21:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D0C7520838 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.com 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 1iziwf-0004nC-5L; Thu, 06 Feb 2020 15:19:57 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iziwd-0004n5-Vz for xen-devel@lists.xenproject.org; Thu, 06 Feb 2020 15:19:56 +0000 X-Inumbo-ID: 20695eb2-48f4-11ea-afdb-12813bfff9fa Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 20695eb2-48f4-11ea-afdb-12813bfff9fa; Thu, 06 Feb 2020 15:19:54 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id A5F49AD6C; Thu, 6 Feb 2020 15:19:53 +0000 (UTC) To: "xen-devel@lists.xenproject.org" From: Jan Beulich Message-ID: Date: Thu, 6 Feb 2020 16:20:02 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.4.2 MIME-Version: 1.0 Content-Language: en-US Subject: [Xen-devel] [PATCH] x86/p2m: drop p2m_access_t parameter from set_mmio_p2m_entry() 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: Kevin Tian , Wei Liu , George Dunlap , Andrew Cooper , Jun Nakajima , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Both callers request the host P2M's default access, which can as well be done inside the function. While touching this anyway, make the "gfn" parameter type-safe as well. Signed-off-by: Jan Beulich Reviewed-by: Roger Pau Monné Reviewed-by: Kevin Tian Acked-by: Andrew Cooper --- a/xen/arch/x86/hvm/vmx/vmx.c +++ b/xen/arch/x86/hvm/vmx/vmx.c @@ -3037,9 +3037,8 @@ static int vmx_alloc_vlapic_mapping(stru share_xen_page_with_guest(pg, d, SHARE_rw); d->arch.hvm.vmx.apic_access_mfn = mfn; - return set_mmio_p2m_entry(d, paddr_to_pfn(APIC_DEFAULT_PHYS_BASE), mfn, - PAGE_ORDER_4K, - p2m_get_hostp2m(d)->default_access); + return set_mmio_p2m_entry(d, gaddr_to_gfn(APIC_DEFAULT_PHYS_BASE), mfn, + PAGE_ORDER_4K); } static void vmx_free_vlapic_mapping(struct domain *d) --- a/xen/arch/x86/mm/p2m.c +++ b/xen/arch/x86/mm/p2m.c @@ -1327,15 +1327,16 @@ int set_foreign_p2m_entry(struct domain p2m_get_hostp2m(d)->default_access); } -int set_mmio_p2m_entry(struct domain *d, unsigned long gfn, mfn_t mfn, - unsigned int order, p2m_access_t access) +int set_mmio_p2m_entry(struct domain *d, gfn_t gfn, mfn_t mfn, + unsigned int order) { if ( order > PAGE_ORDER_4K && rangeset_overlaps_range(mmio_ro_ranges, mfn_x(mfn), mfn_x(mfn) + (1UL << order) - 1) ) return PAGE_ORDER_4K + 1; - return set_typed_p2m_entry(d, gfn, mfn, order, p2m_mmio_direct, access); + return set_typed_p2m_entry(d, gfn_x(gfn), mfn, order, p2m_mmio_direct, + p2m_get_hostp2m(d)->default_access); } int set_identity_p2m_entry(struct domain *d, unsigned long gfn_l, @@ -2305,9 +2306,8 @@ int map_mmio_regions(struct domain *d, for ( order = mmio_order(d, (gfn_x(start_gfn) + i) | (mfn_x(mfn) + i), nr - i); ; order = ret - 1 ) { - ret = set_mmio_p2m_entry(d, gfn_x(start_gfn) + i, - mfn_add(mfn, i), order, - p2m_get_hostp2m(d)->default_access); + ret = set_mmio_p2m_entry(d, gfn_add(start_gfn, i), + mfn_add(mfn, i), order); if ( ret <= 0 ) break; ASSERT(ret <= order); --- a/xen/include/asm-x86/p2m.h +++ b/xen/include/asm-x86/p2m.h @@ -638,8 +638,8 @@ int p2m_is_logdirty_range(struct p2m_dom int set_foreign_p2m_entry(struct domain *d, unsigned long gfn, mfn_t mfn); /* Set mmio addresses in the p2m table (for pass-through) */ -int set_mmio_p2m_entry(struct domain *d, unsigned long gfn, mfn_t mfn, - unsigned int order, p2m_access_t access); +int set_mmio_p2m_entry(struct domain *d, gfn_t gfn, mfn_t mfn, + unsigned int order); int clear_mmio_p2m_entry(struct domain *d, unsigned long gfn, mfn_t mfn, unsigned int order);