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-next>] [day] [month] [year] [list]
Message-Id: <20231030225003.374717-1-singhabhinav9051571833@gmail.com>
Date:   Tue, 31 Oct 2023 04:20:03 +0530
From:   Abhinav Singh <singhabhinav9051571833@...il.com>
To:     linux-hyperv@...r.kernel.org, linux-kernel@...r.kernel.org
Cc:     hpa@...or.com, x86@...nel.org, dave.hansen@...ux.intel.com,
        bp@...en8.de, mingo@...hat.com, tglx@...utronix.de,
        decui@...rosoft.com, wei.liu@...nel.org, haiyangz@...rosoft.com,
        kys@...rosoft.com, niyelchu@...ux.microsoft.com,
        Abhinav Singh <singhabhinav9051571833@...il.com>
Subject: [PATCH v2] x86/hyperv : Fixing removal of __iomem address space warning

This patch fixes two sparse warnings

1. sparse complaining about the removal of __iomem address
space when casting the return value of this ioremap_cache(...)
from `void __ioremap*` to `void*`.
Fixed this by replacing the ioremap_cache(...)
by memremap(...) and using MEMREMAP_DEC and MEMREMAP_WB flag for making
sure the memory is always decrypted and it will support full write back
cache.

2. sparse complaining `expected void volatile [noderef] __iomem *addr`
when calling iounmap with a non __iomem pointer.
Fixed this by replacing iounmap(...) with memumap(...).

Signed-off-by: Abhinav Singh <singhabhinav9051571833@...il.com>
---

v1:
https://lore.kernel.org/all/19cec6f0-e176-4bcc-95a0-9d6eb0261ed1@gmail.com/T/

v1 to v2:
1. Fixed the comment which was earlier describing ioremap_cache(...).
2. Replaced iounmap(...) with memremap(...) inside function hv_cpu_die(...).

 arch/x86/hyperv/hv_init.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c
index 21556ad87f4b..2a14928b8a36 100644
--- a/arch/x86/hyperv/hv_init.c
+++ b/arch/x86/hyperv/hv_init.c
@@ -68,9 +68,11 @@ static int hyperv_init_ghcb(void)
 	 */
 	rdmsrl(MSR_AMD64_SEV_ES_GHCB, ghcb_gpa);

-	/* Mask out vTOM bit. ioremap_cache() maps decrypted */
+	/* Mask out vTOM bit.
+	MEMREMAP_WB full write back cache
+	MEMREMAP_DEC maps decrypted memory */
 	ghcb_gpa &= ~ms_hyperv.shared_gpa_boundary;
-	ghcb_va = (void *)ioremap_cache(ghcb_gpa, HV_HYP_PAGE_SIZE);
+	ghcb_va = memremap(ghcb_gpa, HV_HYP_PAGE_SIZE, MEMREMAP_WB | MEMREMAP_DEC);
 	if (!ghcb_va)
 		return -ENOMEM;

@@ -238,7 +240,7 @@ static int hv_cpu_die(unsigned int cpu)
 	if (hv_ghcb_pg) {
 		ghcb_va = (void **)this_cpu_ptr(hv_ghcb_pg);
 		if (*ghcb_va)
-			iounmap(*ghcb_va);
+			memunmap(*ghcb_va);
 		*ghcb_va = NULL;
 	}

--
2.39.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ