From patchwork Wed Oct 2 21:22:28 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 280178 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 55DDE2C00C3 for ; Thu, 3 Oct 2013 07:22:24 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754260Ab3JBVWW (ORCPT ); Wed, 2 Oct 2013 17:22:22 -0400 Received: from mail-pb0-f44.google.com ([209.85.160.44]:53613 "EHLO mail-pb0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753655Ab3JBVWV (ORCPT ); Wed, 2 Oct 2013 17:22:21 -0400 Received: by mail-pb0-f44.google.com with SMTP id xa7so1470409pbc.17 for ; Wed, 02 Oct 2013 14:22:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=mhOs1QYCWH249kiHb9RlZ7/Xgl43GYzm9LlWvGGXg2k=; b=a4ABvHxAvEG7j/NF5jVeIZeznYXDElVQbA6AURNj1pIbbF9IINlYGjErzY0syg3h62 4L9TYlukUDu/p59VYsHQdmkaj96HNVoM0xYDnFHHNExB3xsi7JFnV4H/ppTvG80DULUa msFLwN5pvdYyFlj7gAEgoGhUFDhyLdFAvVjatoPPnrcDy6d2jaAoXQ/foJMhElHo1pcR n9ZjLTTHRAx+NrmCSWS/BtyRyXxXs4dk8PyJt9/pyCBB7ZB+nbaG5MsnAO14ONPOugEm bgb7XLA1HiU/FOQspenfiW3pNsE/mUKLI2c2m6e3gqKZNUretW2nuWtrCU42Bbd1INly bc1Q== X-Gm-Message-State: ALoCoQnLnE+9qezWbbB05Lj/N9K0utUjyvUIhYaSBaWxmFjalcXHIRIbzJsEqgjMBc302HmbdZbK X-Received: by 10.68.179.161 with SMTP id dh1mr4785785pbc.160.1380748941292; Wed, 02 Oct 2013 14:22:21 -0700 (PDT) Received: from localhost.localdomain (c-67-169-181-221.hsd1.ca.comcast.net. [67.169.181.221]) by mx.google.com with ESMTPSA id fl3sm5678147pad.10.1969.12.31.16.00.00 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 02 Oct 2013 14:22:19 -0700 (PDT) From: Christoffer Dall To: kvm@vger.kernel.org Cc: kvmarm@lists.cs.columbia.edu, kvm-ppc@vger.kernel.org, kvm-ia64@vger.kernel.org, Christoffer Dall Subject: [PATCH 1/6] KVM: Move gfn_to_index to x86 specific code Date: Wed, 2 Oct 2013 14:22:28 -0700 Message-Id: <1380748953-7864-2-git-send-email-christoffer.dall@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1380748953-7864-1-git-send-email-christoffer.dall@linaro.org> References: <1380748953-7864-1-git-send-email-christoffer.dall@linaro.org> Sender: kvm-ppc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm-ppc@vger.kernel.org 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 c76ff74..4134cf6 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 ca645a0..5a1e553 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h @@ -841,13 +841,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) {