From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9CA40C433F5 for ; Fri, 29 Apr 2022 21:01:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1381225AbiD2VEZ (ORCPT ); Fri, 29 Apr 2022 17:04:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1381174AbiD2VD6 (ORCPT ); Fri, 29 Apr 2022 17:03:58 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 09811D3AF1 for ; Fri, 29 Apr 2022 14:00:38 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id b11-20020a5b008b000000b00624ea481d55so8408972ybp.19 for ; Fri, 29 Apr 2022 14:00:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=reply-to:date:in-reply-to:message-id:mime-version:references :subject:from:to:cc; bh=HXnih4STfuZSP9gQw8KiDoHwzhD9DuieHszM+gFMr1Y=; b=XUor+V+kBp1C1oo8PgjLYIomhABX7qX1FK3OvrrssZKV2LGa1wVtR2fX7FmiO3Dj8q s/C6rxtHIM+f10wkgkdP1GT95Jx6oEXtwNbEPDq90hBtuX4SjnwDtDUBv5QH48ULnFZ/ tAj74mheXTeuehfK7ONkYLCNjDfKmNqLgYorwHVPUbnlnkqf3jBceecFM+AIVDnuCFvQ bRIriuLOLIpVBILX99cAWhHrv4CAxzrIqm65Mc7d6UV19o9FOHFQCJauzyU8Z3H/tu14 4zePI93u2GtS4RjN3HvQfKy2lRMr4+TiXkXtyTtCRZATNPODREUDJ7t9fZ4wuOidIQOx gLDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:reply-to:date:in-reply-to:message-id :mime-version:references:subject:from:to:cc; bh=HXnih4STfuZSP9gQw8KiDoHwzhD9DuieHszM+gFMr1Y=; b=nTDSdol2gW51WoCbQWaoZ4dZ/fXRRAufqWFsuI6UBP1KNPo0GczzgatIQOdkkqVc2g Ekez6yv29ZbcwyaoxJrlzx/qT7byPsocNgMtwrsq7/I92oTuzs8nxq0fcbucCdAFqT45 IcoXt0diguGyA9oaeNpq/QTqpVsGYoks58huD2H5eNmHzeIy78MYjdIB7duMzJNkBZaD +osFkjP8dKF+Xhuk80grSdMBhisyoVZOa8vfDbAHxUPm8vUEw2EwbIVKvzda0Tkb0FHT F27LnJfcL6EXRCXSxXXd1IhcLDrpUetF+KI6STjChuJ3WokhuiMRQx7p8FkIczgUvf+A 9w/A== X-Gm-Message-State: AOAM530G3Kp+kuAtQMcJ50tK+J4dAdOxi6bJme7b0frQK0x7gEhPmVDM txyrYBRAjS12gPri7XAHEgcM69toZ6M= X-Google-Smtp-Source: ABdhPJyOiW1bBv1iaSrEwJmsjNe+xWJVUni+JWC9RdV/XBpoocyR86zZqSRIhmMyOrk1oDuZ1D/TpXRitQ0= X-Received: from seanjc.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:3e5]) (user=seanjc job=sendgmr) by 2002:a25:31c2:0:b0:641:660f:230f with SMTP id x185-20020a2531c2000000b00641660f230fmr1364455ybx.472.1651266037988; Fri, 29 Apr 2022 14:00:37 -0700 (PDT) Reply-To: Sean Christopherson Date: Fri, 29 Apr 2022 21:00:22 +0000 In-Reply-To: <20220429210025.3293691-1-seanjc@google.com> Message-Id: <20220429210025.3293691-6-seanjc@google.com> Mime-Version: 1.0 References: <20220429210025.3293691-1-seanjc@google.com> X-Mailer: git-send-email 2.36.0.464.gb9c8b46e94-goog Subject: [PATCH v3 5/8] KVM: Do not incorporate page offset into gfn=>pfn cache user address From: Sean Christopherson To: Paolo Bonzini Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Sean Christopherson , Lai Jiangshan , David Woodhouse , Mingwei Zhang Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Don't adjust the userspace address in the gfn=>pfn cache by the page offset from the gpa. KVM should never use the user address directly, and all KVM operations that translate a user address to something else require the user address to be page aligned. Ignoring the offset will allow the cache to reuse a gfn=>hva translation in the unlikely event that the page offset of the gpa changes, but the gfn does not. And more importantly, not having to (un)adjust the user address will simplify a future bug fix. Cc: stable@vger.kernel.org Signed-off-by: Sean Christopherson --- virt/kvm/pfncache.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/virt/kvm/pfncache.c b/virt/kvm/pfncache.c index 40cbe90d52e0..05cb0bcbf662 100644 --- a/virt/kvm/pfncache.c +++ b/virt/kvm/pfncache.c @@ -179,8 +179,6 @@ int kvm_gfn_to_pfn_cache_refresh(struct kvm *kvm, struct gfn_to_pfn_cache *gpc, ret = -EFAULT; goto out; } - - gpc->uhva += page_offset; } /* -- 2.36.0.464.gb9c8b46e94-goog