Kernel KVM virtualization development
 help / color / mirror / Atom feed
From: Dave Hansen <dave.hansen@intel.com>
To: Sean Christopherson <seanjc@google.com>,
	Zhao Liu <zhao1.liu@linux.intel.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	x86@kernel.org, "H . Peter Anvin" <hpa@zytor.com>,
	kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
	Ira Weiny <ira.weiny@intel.com>,
	"Fabio M . De Francesco" <fmdefrancesco@gmail.com>,
	Zhenyu Wang <zhenyu.z.wang@intel.com>,
	Zhao Liu <zhao1.liu@intel.com>
Subject: Re: [PATCH] KVM: SVM: Replace kmap_atomic() with kmap_local_page()
Date: Fri, 2 Sep 2022 08:25:44 -0700	[thread overview]
Message-ID: <5d667258-b58b-3d28-3609-e7914c99b31b@intel.com> (raw)
In-Reply-To: <YxId/V1qZcie9eyp@google.com>

On 9/2/22 08:15, Sean Christopherson wrote:
>>  	for (i = 0; i < npages; i++) {
>> -		page_virtual = kmap_atomic(pages[i]);
>> +		page_virtual = kmap_local_page(pages[i]);
>>  		clflush_cache_range(page_virtual, PAGE_SIZE);
> SEV is 64-bit only, any reason not to go straight to page_address()?

Yes.  page_address() is a hack.  People get away with using it, but they
really shouldn't, especially when it is used on pages you didn't
allocate yourself.

IOW:

	page = alloc_page(GFP_KERNEL);
	ptr = page_address(page);

is fine.  But:

	page = alloc_page(GFP_HIGHUSER);
	ptr = page_address(page);

even on something that's Kconfig'd 64-bit only is a no-no in my book.
The same goes for a generic-looking function like sev_clflush_pages()
where the pages come from who-knows-where.

It's incredibly useful for kernel accesses to random pages to be bounded
explicitly.  Keeping the kmap() *API* in place means it can be used for
things other than highmem mappings (like protection keys).  The kmap*()
family is a pretty thin wrapper around page_address() on 64-bit most of
the time anyway.


      reply	other threads:[~2022-09-02 15:39 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-02  9:08 [PATCH] KVM: SVM: Replace kmap_atomic() with kmap_local_page() Zhao Liu
2022-09-02 15:09 ` Dave Hansen
2022-09-04 15:54   ` Zhao Liu
2022-09-02 15:15 ` Sean Christopherson
2022-09-02 15:25   ` Dave Hansen [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=5d667258-b58b-3d28-3609-e7914c99b31b@intel.com \
    --to=dave.hansen@intel.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=fmdefrancesco@gmail.com \
    --cc=hpa@zytor.com \
    --cc=ira.weiny@intel.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=seanjc@google.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    --cc=zhao1.liu@intel.com \
    --cc=zhao1.liu@linux.intel.com \
    --cc=zhenyu.z.wang@intel.com \
    /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