mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Abhinav Singh <singhabhinav9051571833@gmail.com>
To: Michael Kelley <mhklinux@outlook.com>,
	"linux-hyperv@vger.kernel.org" <linux-hyperv@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Cc: "hpa@zytor.com" <hpa@zytor.com>,
	"x86@kernel.org" <x86@kernel.org>,
	"dave.hansen@linux.intel.com" <dave.hansen@linux.intel.com>,
	"bp@alien8.de" <bp@alien8.de>,
	"mingo@redhat.com" <mingo@redhat.com>,
	"tglx@linutronix.de" <tglx@linutronix.de>,
	"decui@microsoft.com" <decui@microsoft.com>,
	"wei.liu@kernel.org" <wei.liu@kernel.org>,
	"haiyangz@microsoft.com" <haiyangz@microsoft.com>,
	"kys@microsoft.com" <kys@microsoft.com>,
	"niyelchu@linux.microsoft.com" <niyelchu@linux.microsoft.com>
Subject: Re: [PATCH v2] x86/hyperv : Fixing removal of __iomem address space warning
Date: Mon, 6 Nov 2023 20:53:07 +0530	[thread overview]
Message-ID: <8662a7cc-f18e-43a5-a38f-15212a5f93b8@gmail.com> (raw)
In-Reply-To: <BY3PR18MB46927A33E493191AA4F23B03D4ABA@BY3PR18MB4692.namprd18.prod.outlook.com>

On 11/5/23 20:55, Michael Kelley wrote:
> From: Abhinav Singh <singhabhinav9051571833@gmail.com> Sent: Monday, October 30, 2023 3:50 PM
>>
>> 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@gmail.com>
> 
> Since Nischala has posted her more comprehensive patch,
> this patch can be dropped.  But see one comment below for
> future reference.
> 
>> ---
>>
>> 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 */
> 
> This isn't the right style for multi-line patches.  Correct would be:
> 
> 	/*
> 	 * Mask out vTOM bit.
> 	 * MEMREMAP_WB full write back cache
> 	 * MEMREMAP_DEC maps decrypted memory
> 	 */
> 
> Section 8 of coding-style.rst under Documentation/process covers
> these details.   Note that the style is slightly different for code
> under net and drivers/net.
> 
> Michael
> 
>>   	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
> 
Thanks a lot for taking a look and the suggestion, will keep this in 
mind in future patches.

Thanks,
Abhinav

      reply	other threads:[~2023-11-06 15:23 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-30 22:50 Abhinav Singh
2023-11-05 15:25 ` Michael Kelley
2023-11-06 15:23   ` Abhinav Singh [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8662a7cc-f18e-43a5-a38f-15212a5f93b8@gmail.com \
    --to=singhabhinav9051571833@gmail.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=decui@microsoft.com \
    --cc=haiyangz@microsoft.com \
    --cc=hpa@zytor.com \
    --cc=kys@microsoft.com \
    --cc=linux-hyperv@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mhklinux@outlook.com \
    --cc=mingo@redhat.com \
    --cc=niyelchu@linux.microsoft.com \
    --cc=tglx@linutronix.de \
    --cc=wei.liu@kernel.org \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®