From: "Fabio M. De Francesco" <fmdefrancesco@gmail.com>
To: linux-kernel@vger.kernel.org, linux-sgx@vger.kernel.org,
Jarkko Sakkinen <jarkko@kernel.org>,
Dave Hansen <dave.hansen@linux.intel.com>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
Kristen Carlson Accardi <kristen@linux.intel.com>
Cc: ira.weiny@intel.com, Kristen Carlson Accardi <kristen@linux.intel.com>
Subject: Re: [PATCH] x86/sgx: Replace kmap/kunmap_atomic calls
Date: Thu, 06 Oct 2022 22:37:32 +0200 [thread overview]
Message-ID: <3694452.kQq0lBPeGt@mypc> (raw)
In-Reply-To: <20220929160647.362798-1-kristen@linux.intel.com>
On Thursday, September 29, 2022 6:06:46 PM CEST Kristen Carlson Accardi wrote:
> It is not necessary to disable page faults or preemption when
> using kmap calls
Do you refer to the page faults disabling that kmap_atomic() provides as a
side effect? Can you please clarify a little more? kmap_atomic() disables
always only page faults, instead it might not disable preemption; it depends
on CONFIG_PREEMPT_RT. Therefore, why are you also talking about preemption?
Are you converting code which runs in atomic context regardless kmap_atomic()?
If so, between kmap() and kmap_atomic(), the author(s) had only one choice, it
correctly was kmap_atomic(), otherwise we might end up with a perfect recipe
for triggering SAC bugs.
kmap() were not suited in those cases because it might sleep. If the intents
of the author are simply map a page while in atomic, so to avoid sleeping in
atomic bugs, your conversions looks good.
For the reasons above, can you please say something more about why this code
needed a kmap_atomic() instead of calling kmap()?
A different case is in choosing kmap_atomic() is there because of its side
effects, despite the code is running in non atomic context until the mapping,
but it needs to disable pagefaults only somewhere between the mapping and
unmapping. This is a trickier case than the above-mentioned one because along
with conversion developers should at least disable the pagefaults and
probably, although not necessarily, also disable preemption.
> , so replace kmap_atomic() and kunmap_atomic()
> calls with more the more appropriate kmap_local_page() and
> kunmap_local() calls.
Why is kmap_local_page() better suited in general and is safe in
this specific case?
I think that we should provide the maintainer with well supported reasons why
they should change any piece of code which is still doing what it is thought
for. A mere deprecation in favour of a newer API may not be enough to change
code that is still working properly (like in the old "if it's not broken,
don't fix it!", or something like this :)).
Thanks,
Fabio
>
> Signed-off-by: Kristen Carlson Accardi <kristen@linux.intel.com>
> ---
> arch/x86/kernel/cpu/sgx/encl.c | 12 ++++++------
> arch/x86/kernel/cpu/sgx/ioctl.c | 4 ++--
> arch/x86/kernel/cpu/sgx/main.c | 8 ++++----
> 3 files changed, 12 insertions(+), 12 deletions(-)
>
[snip]
next prev parent reply other threads:[~2022-10-06 20:39 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-29 16:06 [PATCH] x86/sgx: Replace kmap/kunmap_atomic calls Kristen Carlson Accardi
2022-09-30 21:55 ` Jarkko Sakkinen
2022-10-06 20:37 ` Fabio M. De Francesco [this message]
2022-10-06 20:45 ` Dave Hansen
2022-10-06 21:26 ` Ira Weiny
2022-10-06 22:02 ` Fabio M. De Francesco
2022-10-06 22:29 ` Dave Hansen
2022-10-06 23:17 ` Ira Weiny
2022-10-07 15:23 ` Ira Weiny
2022-10-12 7:15 ` Jarkko Sakkinen
2022-10-12 7:26 ` Jarkko Sakkinen
2022-10-12 14:13 ` Dave Hansen
2022-10-12 14:50 ` Jarkko Sakkinen
2022-10-12 15:50 ` Jarkko Sakkinen
2022-10-13 16:03 ` Kristen Carlson Accardi
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=3694452.kQq0lBPeGt@mypc \
--to=fmdefrancesco@gmail.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=ira.weiny@intel.com \
--cc=jarkko@kernel.org \
--cc=kristen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sgx@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
--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