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] [day] [month] [year] [list]
Date:   Wed, 7 Jun 2017 16:27:09 +0300
From:   Andy Shevchenko <andy.shevchenko@...il.com>
To:     Vitaly Kuznetsov <vkuznets@...hat.com>
Cc:     devel@...uxdriverproject.org, "x86@...nel.org" <x86@...nel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "K. Y. Srinivasan" <kys@...rosoft.com>,
        Haiyang Zhang <haiyangz@...rosoft.com>,
        Stephen Hemminger <sthemmin@...rosoft.com>,
        Thomas Gleixner <tglx@...utronix.de>,
        Ingo Molnar <mingo@...hat.com>,
        "H. Peter Anvin" <hpa@...or.com>,
        Steven Rostedt <rostedt@...dmis.org>,
        Jork Loeser <Jork.Loeser@...rosoft.com>,
        Simon Xiao <sixiao@...rosoft.com>,
        Andy Lutomirski <luto@...nel.org>
Subject: Re: [PATCH v7 09/10] x86/hyper-v: support extended CPU ranges for TLB
 flush hypercalls

On Wed, Jun 7, 2017 at 2:01 PM, Vitaly Kuznetsov <vkuznets@...hat.com> wrote:
> Hyper-V hosts may support more than 64 vCPUs, we need to use
> HVCALL_FLUSH_VIRTUAL_ADDRESS_SPACE_EX/LIST_EX hypercalls in this
> case.

> +/* HvFlushVirtualAddressSpaceEx, HvFlushVirtualAddressListEx hypercalls */
> +struct hv_flush_pcpu_ex {
> +       u64 address_space;
> +       u64 flags;
> +       struct {
> +               u64 format;
> +               u64 valid_bank_mask;
> +               u64 bank_contents[];
> +       } hv_vp_set;
> +       u64 gva_list[];
> +};

> +static struct hv_flush_pcpu_ex __percpu *pcpu_flush_ex;

> -               flush->address_space = virt_to_phys(mm->pgd);
> +               flush->address_space = (u64)virt_to_phys(mm->pgd);

I think this casting is redundant. Your variable fits phys_addr_t
always. Like you do below w/o explicit casting.

> +static void hyperv_flush_tlb_others_ex(const struct cpumask *cpus,
> +                                      struct mm_struct *mm,
> +                                      unsigned long start,
> +                                      unsigned long end)
> +{
> +       int nr_bank = 0, max_gvas, gva_n;
> +       struct hv_flush_pcpu_ex *flush;

> +       u64 status = U64_MAX;

In one of the previous patches you used (u64)ULLONG_MAX.
I recommend to use _there_ same as here, i.e. = U64_MAX;

> +       if (mm) {
> +               flush->address_space = virt_to_phys(mm->pgd);

No explicit casting is okay here.

> +               flush->flags = 0;
> +       } else {
> +               flush->address_space = 0;
> +               flush->flags = HV_FLUSH_ALL_VIRTUAL_ADDRESS_SPACES;
> +       }

> +       /*
> +        * We can flush not more than max_gvas with one hypercall. Flush the
> +        * whole address space if we were asked to do more.
> +        */
> +       max_gvas = (PAGE_SIZE - sizeof(*flush) -
> +                   nr_bank * sizeof(flush->hv_vp_set.bank_contents[0])) /
> +               sizeof(flush->gva_list[0]);

Is it possible to re-indent like
    max_gvas =
        (PAGE_SIZE - sizeof(*flush) - nr_bank *
sizeof(flush->hv_vp_set.bank_contents[0])) /
        sizeof(flush->gva_list[0]);

for easier understanding the calculus?

-- 
With Best Regards,
Andy Shevchenko

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ