From patchwork Thu Mar 3 16:38:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 8493961 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id C0794C0553 for ; Thu, 3 Mar 2016 16:40:56 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B833220173 for ; Thu, 3 Mar 2016 16:40:55 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A1E2820351 for ; Thu, 3 Mar 2016 16:40:54 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xen.org with esmtp (Exim 4.84) (envelope-from ) id 1abWGj-0003vd-AP; Thu, 03 Mar 2016 16:38:29 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.84) (envelope-from ) id 1abWGi-0003vG-56 for xen-devel@lists.xenproject.org; Thu, 03 Mar 2016 16:38:28 +0000 Received: from [85.158.137.68] by server-2.bemta-3.messagelabs.com id 41/19-03293-38868D65; Thu, 03 Mar 2016 16:38:27 +0000 X-Env-Sender: JBeulich@suse.com X-Msg-Ref: server-6.tower-31.messagelabs.com!1457023104!499546!1 X-Originating-IP: [137.65.248.74] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.11; banners=-,-,- X-VirusChecked: Checked Received: (qmail 56869 invoked from network); 3 Mar 2016 16:38:26 -0000 Received: from prv-mh.provo.novell.com (HELO prv-mh.provo.novell.com) (137.65.248.74) by server-6.tower-31.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 3 Mar 2016 16:38:26 -0000 Received: from INET-PRV-MTA by prv-mh.provo.novell.com with Novell_GroupWise; Thu, 03 Mar 2016 09:38:24 -0700 Message-Id: <56D8769002000078000D8F79@prv-mh.provo.novell.com> X-Mailer: Novell GroupWise Internet Agent 14.2.0 Date: Thu, 03 Mar 2016 09:38:24 -0700 From: "Jan Beulich" To: "xen-devel" References: <56D8745B02000078000D8F22@prv-mh.provo.novell.com> In-Reply-To: <56D8745B02000078000D8F22@prv-mh.provo.novell.com> Mime-Version: 1.0 Cc: Andrew Cooper , Keir Fraser , Wei Liu , Tim Deegan Subject: [Xen-devel] [PATCH 5/6] x86/HVM: adjust hvm_get_mem_pinned_cacheattr() GFN parameter X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Make it gfn_t and rename it accordingly. Suggested-by: Andrew Cooper Signed-off-by: Jan Beulich x86/HVM: adjust hvm_get_mem_pinned_cacheattr() GFN parameter Make it gfn_t and rename it accordingly. Suggested-by: Andrew Cooper Signed-off-by: Jan Beulich --- a/xen/arch/x86/hvm/mtrr.c +++ b/xen/arch/x86/hvm/mtrr.c @@ -545,7 +545,7 @@ void hvm_destroy_cacheattr_region_list( int hvm_get_mem_pinned_cacheattr( struct domain *d, - uint64_t guest_fn, + gfn_t gfn, unsigned int order) { struct hvm_mem_pinned_cacheattr_range *range; @@ -559,14 +559,14 @@ int hvm_get_mem_pinned_cacheattr( &d->arch.hvm_domain.pinned_cacheattr_ranges, list ) { - if ( ((guest_fn & mask) >= range->start) && - ((guest_fn | ~mask) <= range->end) ) + if ( ((gfn_x(gfn) & mask) >= range->start) && + ((gfn_x(gfn) | ~mask) <= range->end) ) { rc = range->type; break; } - if ( ((guest_fn & mask) <= range->end) && - (range->start <= (guest_fn | ~mask)) ) + if ( ((gfn_x(gfn) & mask) <= range->end) && + ((gfn_x(gfn) | ~mask) >= range->start) ) { rc = -EADDRNOTAVAIL; break; @@ -808,7 +808,7 @@ int epte_get_entry_emt(struct domain *d, return MTRR_TYPE_WRBACK; } - gmtrr_mtype = hvm_get_mem_pinned_cacheattr(d, gfn, order); + gmtrr_mtype = hvm_get_mem_pinned_cacheattr(d, _gfn(gfn), order); if ( gmtrr_mtype >= 0 ) { *ipat = 1; --- a/xen/arch/x86/mm/shadow/multi.c +++ b/xen/arch/x86/mm/shadow/multi.c @@ -619,8 +619,7 @@ _sh_propagate(struct vcpu *v, * gMTRR and gPAT. */ if ( !mmio_mfn && - (type = hvm_get_mem_pinned_cacheattr(d, gfn_x(target_gfn), - 0)) >= 0 ) + (type = hvm_get_mem_pinned_cacheattr(d, target_gfn, 0)) >= 0 ) sflags |= pat_type_2_pte_flags(type); else if ( d->arch.hvm_domain.is_in_uc_mode ) sflags |= pat_type_2_pte_flags(PAT_TYPE_UNCACHABLE); --- a/xen/include/asm-x86/hvm/cacheattr.h +++ b/xen/include/asm-x86/hvm/cacheattr.h @@ -1,20 +1,22 @@ #ifndef __HVM_CACHEATTR_H__ #define __HVM_CACHEATTR_H__ +#include + void hvm_init_cacheattr_region_list( struct domain *d); void hvm_destroy_cacheattr_region_list( struct domain *d); /* - * To see guest_fn is in the pinned range or not, + * Check whether gfn is in the pinned range: * if yes, return 1, and set type to value in this range * if no, return 0, setting type to ~0 * if ambiguous, return -1, setting type to ~0 (possible only for order > 0) */ int hvm_get_mem_pinned_cacheattr( struct domain *d, - uint64_t guest_fn, + gfn_t gfn, unsigned int order); Reviewed-by: Andrew Cooper --- a/xen/arch/x86/hvm/mtrr.c +++ b/xen/arch/x86/hvm/mtrr.c @@ -545,7 +545,7 @@ void hvm_destroy_cacheattr_region_list( int hvm_get_mem_pinned_cacheattr( struct domain *d, - uint64_t guest_fn, + gfn_t gfn, unsigned int order) { struct hvm_mem_pinned_cacheattr_range *range; @@ -559,14 +559,14 @@ int hvm_get_mem_pinned_cacheattr( &d->arch.hvm_domain.pinned_cacheattr_ranges, list ) { - if ( ((guest_fn & mask) >= range->start) && - ((guest_fn | ~mask) <= range->end) ) + if ( ((gfn_x(gfn) & mask) >= range->start) && + ((gfn_x(gfn) | ~mask) <= range->end) ) { rc = range->type; break; } - if ( ((guest_fn & mask) <= range->end) && - (range->start <= (guest_fn | ~mask)) ) + if ( ((gfn_x(gfn) & mask) <= range->end) && + ((gfn_x(gfn) | ~mask) >= range->start) ) { rc = -EADDRNOTAVAIL; break; @@ -808,7 +808,7 @@ int epte_get_entry_emt(struct domain *d, return MTRR_TYPE_WRBACK; } - gmtrr_mtype = hvm_get_mem_pinned_cacheattr(d, gfn, order); + gmtrr_mtype = hvm_get_mem_pinned_cacheattr(d, _gfn(gfn), order); if ( gmtrr_mtype >= 0 ) { *ipat = 1; --- a/xen/arch/x86/mm/shadow/multi.c +++ b/xen/arch/x86/mm/shadow/multi.c @@ -619,8 +619,7 @@ _sh_propagate(struct vcpu *v, * gMTRR and gPAT. */ if ( !mmio_mfn && - (type = hvm_get_mem_pinned_cacheattr(d, gfn_x(target_gfn), - 0)) >= 0 ) + (type = hvm_get_mem_pinned_cacheattr(d, target_gfn, 0)) >= 0 ) sflags |= pat_type_2_pte_flags(type); else if ( d->arch.hvm_domain.is_in_uc_mode ) sflags |= pat_type_2_pte_flags(PAT_TYPE_UNCACHABLE); --- a/xen/include/asm-x86/hvm/cacheattr.h +++ b/xen/include/asm-x86/hvm/cacheattr.h @@ -1,20 +1,22 @@ #ifndef __HVM_CACHEATTR_H__ #define __HVM_CACHEATTR_H__ +#include + void hvm_init_cacheattr_region_list( struct domain *d); void hvm_destroy_cacheattr_region_list( struct domain *d); /* - * To see guest_fn is in the pinned range or not, + * Check whether gfn is in the pinned range: * if yes, return 1, and set type to value in this range * if no, return 0, setting type to ~0 * if ambiguous, return -1, setting type to ~0 (possible only for order > 0) */ int hvm_get_mem_pinned_cacheattr( struct domain *d, - uint64_t guest_fn, + gfn_t gfn, unsigned int order);