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: <69b46bf3-40ab-c379-03d5-efd537ed44c7@intel.com>
Date:   Fri, 11 Aug 2023 07:09:40 -0700
From:   Dave Hansen <dave.hansen@...el.com>
To:     Dexuan Cui <decui@...rosoft.com>, x86@...nel.org,
        ak@...ux.intel.com, arnd@...db.de, bp@...en8.de,
        brijesh.singh@....com, dan.j.williams@...el.com,
        dave.hansen@...ux.intel.com, haiyangz@...rosoft.com, hpa@...or.com,
        jane.chu@...cle.com, kirill.shutemov@...ux.intel.com,
        kys@...rosoft.com, luto@...nel.org, mingo@...hat.com,
        peterz@...radead.org, rostedt@...dmis.org,
        sathyanarayanan.kuppuswamy@...ux.intel.com, seanjc@...gle.com,
        tglx@...utronix.de, tony.luck@...el.com, wei.liu@...nel.org,
        Jason@...c4.com, nik.borisov@...e.com, mikelley@...rosoft.com
Cc:     linux-hyperv@...r.kernel.org, linux-kernel@...r.kernel.org,
        Tianyu.Lan@...rosoft.com, rick.p.edgecombe@...el.com,
        andavis@...hat.com, mheslin@...hat.com, vkuznets@...hat.com,
        xiaoyao.li@...el.com
Subject: Re: [PATCH RESEND v9 2/2] x86/tdx: Support vmalloc() for
 tdx_enc_status_changed()

On 8/10/23 19:12, Dexuan Cui wrote:
> +	if (!is_vmalloc_addr((void *)start))
> +		return tdx_enc_status_changed_phys(__pa(start), __pa(end), enc);
> +
> +	while (start < end) {
> +		phys_addr_t start_pa = slow_virt_to_phys((void *)start);
> +		phys_addr_t end_pa = start_pa + PAGE_SIZE;
> +
> +		if (!tdx_enc_status_changed_phys(start_pa, end_pa, enc))
> +			return false;
> +
> +		start += PAGE_SIZE;
> +	}

This creates two different paths for vmalloc() and the direct map.
There are two different ways to do va=>pa conversion, for instance.
Here's a single loop that works for both cases:

	unsigned long step = end - start;
	unsigned long addr;

	/* Step through page-by-page for vmalloc() mappings: */
	if (is_vmalloc_addr((void *)vaddr))
		step = PAGE_SIZE;

	for (addr = start; addr < end; addr += step) {
		phys_addr_t start_pa = slow_virt_to_phys(addr);
		phys_addr_t end_pa   = start_pa + step;

		if (!tdx_enc_status_changed_phys(start_pa, end_pa, enc))
			return false;
	}

Note that this also doesn't abuse 'start' by making it a loop variable.
It also, uh, uses a for() loop.

The only downside is that it costs a page table walk for direct map
virt=>phys conversion.  I can live with that.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ