lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CANgfPd9JrE3Mrbbb4Kc+jfDU+hi65XuPY2HVkqgxTF2g4DAD1g@mail.gmail.com>
Date:   Tue, 27 Oct 2020 15:13:30 -0700
From:   Ben Gardon <bgardon@...gle.com>
To:     Sean Christopherson <sean.j.christopherson@...el.com>
Cc:     Paolo Bonzini <pbonzini@...hat.com>,
        Vitaly Kuznetsov <vkuznets@...hat.com>,
        Wanpeng Li <wanpengli@...cent.com>,
        Jim Mattson <jmattson@...gle.com>,
        Joerg Roedel <joro@...tes.org>, kvm <kvm@...r.kernel.org>,
        LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 2/3] KVM: x86/mmu: Open code GFN "rounding" in TDP MMU

On Tue, Oct 27, 2020 at 2:43 PM Sean Christopherson
<sean.j.christopherson@...el.com> wrote:
>
> Drop round_gfn_for_level() and directly use the recently introdocued
> KVM_HPAGE_GFN_MASK() macro.  Hiding the masking in a "rounding" function
> adds an extra "what does this do?" lookup, whereas the concept and usage
> of PFN/GFN masks is common enough that it's easy to read the open coded
> version without thinking too hard.
>
> No functional change intended.
>
> Cc: Ben Gardon <bgardon@...gle.com>
> Signed-off-by: Sean Christopherson <sean.j.christopherson@...el.com>

Reviewed-by: Ben Gardon <bgardon@...gle.com>

> ---
>  arch/x86/kvm/mmu/tdp_iter.c | 11 +++--------
>  1 file changed, 3 insertions(+), 8 deletions(-)
>
> diff --git a/arch/x86/kvm/mmu/tdp_iter.c b/arch/x86/kvm/mmu/tdp_iter.c
> index c6e914c96641..4175947dc401 100644
> --- a/arch/x86/kvm/mmu/tdp_iter.c
> +++ b/arch/x86/kvm/mmu/tdp_iter.c
> @@ -15,11 +15,6 @@ static void tdp_iter_refresh_sptep(struct tdp_iter *iter)
>         iter->old_spte = READ_ONCE(*iter->sptep);
>  }
>
> -static gfn_t round_gfn_for_level(gfn_t gfn, int level)
> -{
> -       return gfn & KVM_HPAGE_GFN_MASK(level);
> -}
> -
>  /*
>   * Sets a TDP iterator to walk a pre-order traversal of the paging structure
>   * rooted at root_pt, starting with the walk to translate goal_gfn.
> @@ -36,7 +31,7 @@ void tdp_iter_start(struct tdp_iter *iter, u64 *root_pt, int root_level,
>         iter->level = root_level;
>         iter->pt_path[iter->level - 1] = root_pt;
>
> -       iter->gfn = round_gfn_for_level(iter->goal_gfn, iter->level);
> +       iter->gfn = iter->goal_gfn & KVM_HPAGE_GFN_MASK(iter->level);
>         tdp_iter_refresh_sptep(iter);
>
>         iter->valid = true;
> @@ -82,7 +77,7 @@ static bool try_step_down(struct tdp_iter *iter)
>
>         iter->level--;
>         iter->pt_path[iter->level - 1] = child_pt;
> -       iter->gfn = round_gfn_for_level(iter->goal_gfn, iter->level);
> +       iter->gfn = iter->goal_gfn & KVM_HPAGE_GFN_MASK(iter->level);
>         tdp_iter_refresh_sptep(iter);
>
>         return true;
> @@ -124,7 +119,7 @@ static bool try_step_up(struct tdp_iter *iter)
>                 return false;
>
>         iter->level++;
> -       iter->gfn = round_gfn_for_level(iter->gfn, iter->level);
> +       iter->gfn &= KVM_HPAGE_GFN_MASK(iter->level);
>         tdp_iter_refresh_sptep(iter);
>
>         return true;
> --
> 2.28.0
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ