From patchwork Fri Aug 9 04:07:17 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 18905 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qe0-f70.google.com (mail-qe0-f70.google.com [209.85.128.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 2331325E16 for ; Fri, 9 Aug 2013 04:07:31 +0000 (UTC) Received: by mail-qe0-f70.google.com with SMTP id 6sf4599295qeb.1 for ; Thu, 08 Aug 2013 21:07:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-gm-message-state:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=4h7ru9lR7bYixXIiQIxRJCQi+VHS7kmuBk45w/Z3jn4=; b=EV5bDA5CSMQhV3WuIDHYJowE5AQDXlxCGJ4SjYjOodz0eDLXRTa+4K9qLgtlWVbgyJ r1qIA8YHU0cig4uuaxsCeWlTVpu/lx6yalZPInQRwB8D/bSff4Ux/vdwcXG/11XkuIsS W9bQkL42P2aIjh5bRMH9YTXmJq5XOeAGTBaliZ6WLlZ+jdtmyvgxvVG2K8ymUS6CFd/E TTdZD8DWqPF83Biu7dLbkeeHsNxyjrM9HwO6x/iJPIehrXE0onypJb3i4aokGKA+rHPw S2wIMSYfrm9WFVkKtrS+n/mn0mFc02mvQ9lTpxJqEsT7j4TGOj0+jKTs/Q95CVJtxjFt AFPQ== X-Received: by 10.236.148.33 with SMTP id u21mr4357887yhj.37.1376021250883; Thu, 08 Aug 2013 21:07:30 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.49.196 with SMTP id w4ls1369246qen.71.gmail; Thu, 08 Aug 2013 21:07:30 -0700 (PDT) X-Received: by 10.220.50.10 with SMTP id x10mr3821205vcf.86.1376021250760; Thu, 08 Aug 2013 21:07:30 -0700 (PDT) Received: from mail-vc0-f174.google.com (mail-vc0-f174.google.com [209.85.220.174]) by mx.google.com with ESMTPS id jf10si4100779vdb.102.2013.08.08.21.07.30 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 08 Aug 2013 21:07:30 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.174 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.174; Received: by mail-vc0-f174.google.com with SMTP id gd11so705145vcb.5 for ; Thu, 08 Aug 2013 21:07:30 -0700 (PDT) X-Gm-Message-State: ALoCoQnZN8BZpHkIUlRlwdtE0KVqQJqzuRLsOBcCCbqNyrjiv697o+h/JzcXgLDjcwCYFzsbGW40 X-Received: by 10.220.164.138 with SMTP id e10mr5775106vcy.27.1376021250646; Thu, 08 Aug 2013 21:07:30 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp51760vcz; Thu, 8 Aug 2013 21:07:30 -0700 (PDT) X-Received: by 10.68.60.132 with SMTP id h4mr9304899pbr.177.1376021249640; Thu, 08 Aug 2013 21:07:29 -0700 (PDT) Received: from mail-pa0-f45.google.com (mail-pa0-f45.google.com [209.85.220.45]) by mx.google.com with ESMTPS id hb3si11851427pac.181.2013.08.08.21.07.29 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 08 Aug 2013 21:07:29 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.45 is neither permitted nor denied by best guess record for domain of christoffer.dall@linaro.org) client-ip=209.85.220.45; Received: by mail-pa0-f45.google.com with SMTP id bg4so4491227pad.4 for ; Thu, 08 Aug 2013 21:07:29 -0700 (PDT) X-Received: by 10.68.221.138 with SMTP id qe10mr9395051pbc.103.1376021249173; Thu, 08 Aug 2013 21:07:29 -0700 (PDT) Received: from localhost.localdomain (c-67-169-183-77.hsd1.ca.comcast.net. [67.169.183.77]) by mx.google.com with ESMTPSA id mr3sm17525229pbb.27.2013.08.08.21.07.27 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 08 Aug 2013 21:07:28 -0700 (PDT) From: Christoffer Dall To: kvmarm@lists.cs.columbia.edu Cc: kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linaro-kernel@lists.linaro.org, patches@linaro.org, Christoffer Dall Subject: [PATCH 1/3] KVM: Move gfn_to_index to x86 specific code Date: Thu, 8 Aug 2013 21:07:17 -0700 Message-Id: <1376021239-10532-2-git-send-email-christoffer.dall@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1376021239-10532-1-git-send-email-christoffer.dall@linaro.org> References: <1376021239-10532-1-git-send-email-christoffer.dall@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: christoffer.dall@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.174 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , The gfn_to_index function relies on huge page defines which either may not make sense on systems that don't support huge pages or are defined in an unconvenient way for other architectures. Since this is x86-specific, move the function to arch/x86/include/asm/kvm_host.h. Signed-off-by: Christoffer Dall --- arch/x86/include/asm/kvm_host.h | 7 +++++++ include/linux/kvm_host.h | 7 ------- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index f87f7fc..fca7f2e 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -79,6 +79,13 @@ #define KVM_HPAGE_MASK(x) (~(KVM_HPAGE_SIZE(x) - 1)) #define KVM_PAGES_PER_HPAGE(x) (KVM_HPAGE_SIZE(x) / PAGE_SIZE) +static inline gfn_t gfn_to_index(gfn_t gfn, gfn_t base_gfn, int level) +{ + /* KVM_HPAGE_GFN_SHIFT(PT_PAGE_TABLE_LEVEL) must be 0. */ + return (gfn >> KVM_HPAGE_GFN_SHIFT(level)) - + (base_gfn >> KVM_HPAGE_GFN_SHIFT(level)); +} + #define SELECTOR_TI_MASK (1 << 2) #define SELECTOR_RPL_MASK 0x03 diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index a63d83e..635e098 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h @@ -828,13 +828,6 @@ static inline int memslot_id(struct kvm *kvm, gfn_t gfn) return gfn_to_memslot(kvm, gfn)->id; } -static inline gfn_t gfn_to_index(gfn_t gfn, gfn_t base_gfn, int level) -{ - /* KVM_HPAGE_GFN_SHIFT(PT_PAGE_TABLE_LEVEL) must be 0. */ - return (gfn >> KVM_HPAGE_GFN_SHIFT(level)) - - (base_gfn >> KVM_HPAGE_GFN_SHIFT(level)); -} - static inline gfn_t hva_to_gfn_memslot(unsigned long hva, struct kvm_memory_slot *slot) {