From patchwork Tue Mar 1 22:34:51 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Feiner X-Patchwork-Id: 8471101 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id CD52C9F2F0 for ; Tue, 1 Mar 2016 22:35:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0766C20304 for ; Tue, 1 Mar 2016 22:35:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2FB682034A for ; Tue, 1 Mar 2016 22:35:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751728AbcCAWfT (ORCPT ); Tue, 1 Mar 2016 17:35:19 -0500 Received: from mail-pa0-f46.google.com ([209.85.220.46]:33136 "EHLO mail-pa0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750862AbcCAWfR (ORCPT ); Tue, 1 Mar 2016 17:35:17 -0500 Received: by mail-pa0-f46.google.com with SMTP id fl4so119915974pad.0 for ; Tue, 01 Mar 2016 14:35:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=lQIk/r8Z9QnL1Q9HtQMB8BEnx24qqc662rO9YABar7Y=; b=h1p6xvxJr6+CIz770e2RcToT4uDCTdD+fj/uPcSl2PNx6izqjgbSC5hUZVIJLpL0p0 UyHQB4b+r26yCdwC/AOh+LrPGmY0bQ/4/xDh9YKUwKl3/qDupZGSGzEaiLZ3rgyg0WCZ 79D52zGDUeb2g4qn7bqiGizjSNw/yBwjEDVmyLBPyXE9CxGSSQQYWQBj+uUeoy+VSjU/ F4qERKT91MhQ89szioXg8vNh5iE1jobD0NCTtgw2UpzVEyMs6HDwnYoVr+PckTe0bYvv xJCq9hvLKgBWWHAaOIJPx50qkEgqKo9EyKpBir8Cf1/HBvOh5+JQLuETXvTyXKYS1T65 96Hw== 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=lQIk/r8Z9QnL1Q9HtQMB8BEnx24qqc662rO9YABar7Y=; b=RGHeZK44xWdtJnCybUv0Xn8EiWM3msWlFed++g1Xd+v9CfPcJc6mqPrbDeSuJ+i/7R SD0d46JDY/aOeZheTPqjeWfmumfCLiwId5v6v8t6MGegB754j66bT8sm5Io8IAL6JJ1X CapUksvRIzLQMSDAamqRrnnhopeqnFzVrOnqRyipVDeZ/zz6NQs5Zi7/Lx4CEZ1ruv7S nnIIgBm5YCXE+w6R9hD2qR9++1Ve/Y12lXfvUOH3kvZf81wjlRvn71Fp6rt/ela3KakD JfM2BAMdQtc8hIV1XdoLt0Ko6EnRPSCp6208/PDNuAHczXoOr56uuxq1cUPHST6zQ16S j4QA== X-Gm-Message-State: AD7BkJI1Vlt27iKond2UC69uTnpg3PPCosajKIrV1+QOjZxEbu5lN3K8Y6XqMidBILv85rmG X-Received: by 10.66.217.230 with SMTP id pb6mr33968450pac.63.1456871716522; Tue, 01 Mar 2016 14:35:16 -0800 (PST) Received: from localhost ([2620:0:1009:3:b1e9:1d95:1ce5:e70c]) by smtp.gmail.com with ESMTPSA id p9sm33047630pfj.67.2016.03.01.14.35.14 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Tue, 01 Mar 2016 14:35:15 -0800 (PST) From: Peter Feiner To: kvm@vger.kernel.org, jan.kiszka@siemens.com, drjones@redhat.com, pbonzini@redhat.com Cc: pfeiner@google.com Subject: [kvm-unit-tests v2 3/6] x86: vmx: Named constant: EPT_ADDR_MASK Date: Tue, 1 Mar 2016 14:34:51 -0800 Message-Id: <1456871694-23042-4-git-send-email-pfeiner@google.com> X-Mailer: git-send-email 2.7.0.rc3.207.g0ac5344 In-Reply-To: <1456871694-23042-1-git-send-email-pfeiner@google.com> References: <1456860622-31251-1-git-send-email-pfeiner@google.com> <1456871694-23042-1-git-send-email-pfeiner@google.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, 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 Signed-off-by: Peter Feiner --- x86/vmx.c | 6 +++--- x86/vmx.h | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/x86/vmx.c b/x86/vmx.c index 3fa1a73..9811a28 100644 --- a/x86/vmx.c +++ b/x86/vmx.c @@ -246,7 +246,7 @@ void install_ept_entry(unsigned long *pml4, | EPT_RA | EPT_WA | EPT_EA; } else pt[offset] &= ~EPT_LARGE_PAGE; - pt = phys_to_virt(pt[offset] & 0xffffffffff000ull); + pt = phys_to_virt(pt[offset] & EPT_ADDR_MASK); } offset = ((unsigned long)guest_addr >> ((level-1) * EPT_PGDIR_WIDTH + 12)) & EPT_PGDIR_MASK; @@ -334,7 +334,7 @@ unsigned long get_ept_pte(unsigned long *pml4, break; if (l < 4 && (pte & EPT_LARGE_PAGE)) return pte; - pt = (unsigned long *)(pte & 0xffffffffff000ull); + pt = (unsigned long *)(pte & EPT_ADDR_MASK); } offset = (guest_addr >> (((l-1) * EPT_PGDIR_WIDTH) + 12)) & EPT_PGDIR_MASK; @@ -378,7 +378,7 @@ int set_ept_pte(unsigned long *pml4, unsigned long guest_addr, break; if (!(pt[offset] & (EPT_PRESENT))) return -1; - pt = (unsigned long *)(pt[offset] & 0xffffffffff000ull); + pt = (unsigned long *)(pt[offset] & EPT_ADDR_MASK); } offset = (guest_addr >> (((l-1) * EPT_PGDIR_WIDTH) + 12)) & EPT_PGDIR_MASK; diff --git a/x86/vmx.h b/x86/vmx.h index 8b79191..616ffc0 100644 --- a/x86/vmx.h +++ b/x86/vmx.h @@ -3,6 +3,7 @@ #include "libcflat.h" #include "processor.h" +#include "bitops.h" struct vmcs { u32 revision_id; /* vmcs revision identifier */ @@ -466,6 +467,7 @@ enum Ctrl1 { #define EPT_PAGE_LEVEL 4 #define EPT_PGDIR_WIDTH 9 #define EPT_PGDIR_MASK 511 +#define EPT_ADDR_MASK GENMASK(52, 11) #define PAGE_MASK (~(PAGE_SIZE-1)) #define PAGE_MASK_2M (~(PAGE_SIZE_2M-1))