From patchwork Wed Mar 2 17:10:54 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Feiner X-Patchwork-Id: 8483911 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 DEF119F96D for ; Wed, 2 Mar 2016 17:11:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 08F912038A for ; Wed, 2 Mar 2016 17:11:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0442A20383 for ; Wed, 2 Mar 2016 17:11:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754586AbcCBRLL (ORCPT ); Wed, 2 Mar 2016 12:11:11 -0500 Received: from mail-pf0-f180.google.com ([209.85.192.180]:35901 "EHLO mail-pf0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754515AbcCBRLF (ORCPT ); Wed, 2 Mar 2016 12:11:05 -0500 Received: by mail-pf0-f180.google.com with SMTP id 63so7802640pfe.3 for ; Wed, 02 Mar 2016 09:11:05 -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=DI2BzJ1qaYcYbEDxyGE7+FfyChfWkkyMbf9M192L4AM=; b=FnLDpxsF8HSCpJs/rkbAxSviKjasfCbYvgXwrVDEMccy2rciGSPCGbBxOQZMsZJmdV 4RvwWRWJzMZ0LWEsasUtzO555bL0yo+Suziv30qe8HwTnuYhvd/i9abMwT735kkEjl6I ebUYihEAVqWlx1U8ePYoc+2Ms5wkWf/fDqVASBeoPwlMaiHiaS3VzY21R6ix/FQalYSK yXEMfvpYMITIsj5noiv3IsPD14EhrUIxo4dX3t65nFsGhuCUQ6BYiqLgebgeDVVvQ9l1 fwAAVMuctyY6hN5TA/3rictqDdy4WRNLtepF5ZVZTFtcWt/Y0GcCAhLt/KBedzf5pFA7 gwsA== 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=DI2BzJ1qaYcYbEDxyGE7+FfyChfWkkyMbf9M192L4AM=; b=U80M/zhfuCMxlB3O6ApBF1VjmUSMDi41oBMTj9IdwxTsFnjYU+2YyqSDwqVtmxPbVw tlGu5CpVBbtA6NWf47NNCacOFdl+Bt/65qhFQrKEzPlpwqlXF4svxEKjsDZPPyTmxrYt 4vXTSdHD1G4EmJfm2fPI5y59jCyaXdw+gcXQz0QlElSWyo9JUHNWicVqeDIzKVrjLmYw PZCbOBcGVUtO5t764KJVKGhUh7CwQdel3nxrwVqhrG/ajeeudDncvB0Br2ZOlRsyUPh0 etTFt2JGfOH8IgiH8Ui6Wwq7WIAO8JezanhJpO5LZw4zNDNKOr+1bDKVDk+BRybonew9 gGgA== X-Gm-Message-State: AD7BkJLK9nD7puNBNXJh8LCpS2DyJORM4kll0RpuzUG5D17flJrKLK6dpOY4VPYfBjRyrHtS X-Received: by 10.98.19.215 with SMTP id 84mr40175051pft.22.1456938664647; Wed, 02 Mar 2016 09:11:04 -0800 (PST) Received: from localhost ([2620:0:1009:3:10b2:1b3a:febc:1b15]) by smtp.gmail.com with ESMTPSA id ql1sm14054628pac.24.2016.03.02.09.11.03 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Wed, 02 Mar 2016 09:11:04 -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 v3 3/6] x86: vmx: Named constant: EPT_ADDR_MASK Date: Wed, 2 Mar 2016 09:10:54 -0800 Message-Id: <1456938657-20850-4-git-send-email-pfeiner@google.com> X-Mailer: git-send-email 2.7.0.rc3.207.g0ac5344 In-Reply-To: <1456938657-20850-1-git-send-email-pfeiner@google.com> References: <1456860622-31251-1-git-send-email-pfeiner@google.com> <1456938657-20850-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=ham 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..459dd13 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_ULL(51, 12) #define PAGE_MASK (~(PAGE_SIZE-1)) #define PAGE_MASK_2M (~(PAGE_SIZE_2M-1))