mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: maobibo <maobibo@loongson.cn>
To: Xi Ruoyao <xry111@xry111.site>, WANG Xuerui <kernel@xen0n.name>,
	Huacai Chen <chenhuacai@kernel.org>,
	Tianrui Zhao <zhaotianrui@loongson.cn>,
	Juergen Gross <jgross@suse.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Jonathan Corbet <corbet@lwn.net>
Cc: loongarch@lists.linux.dev, linux-kernel@vger.kernel.org,
	virtualization@lists.linux.dev, kvm@vger.kernel.org
Subject: Re: [PATCH v7 3/7] LoongArch: KVM: Add cpucfg area for kvm hypervisor
Date: Tue, 2 Apr 2024 11:04:14 +0800	[thread overview]
Message-ID: <4d35124d-527d-ec1c-1eb1-2d98e9d0da46@loongson.cn> (raw)
In-Reply-To: <b7d91c1a42470821983a811a16f9fc1c55cfe699.camel@xry111.site>



On 2024/4/2 上午10:49, Xi Ruoyao wrote:
> On Tue, 2024-04-02 at 09:43 +0800, maobibo wrote:
>>> Sorry for the late reply, but I think it may be a bit non-constructive
>>> to repeatedly submit the same code without due explanation in our
>>> previous review threads. Let me try to recollect some of the details
>>> though...
>> Because your review comments about hypercall method is wrong, I need not
>> adopt it.
> 
> Again it's unfair to say so considering the lack of LVZ documentation.
> 
> /* snip */
> 
>>
>> 1. T0-T7 are scratch registers during SYSCALL ABI, this is what you
>> suggest, does there exist information leaking to user space from T0-T7
>> registers?
> 
> It's not a problem.  When syscall returns RESTORE_ALL_AND_RET is invoked
> despite T0-T7 are not saved.  So a "junk" value will be read from the
> leading PT_SIZE bytes of the kernel stack for this thread.
For you it is "junk" value, some guys maybe thinks it is useful.

There is another issue, since kernel restore T0-T7 registers and user 
space save T0-T7. Why T0-T7 is scratch registers rather than preserve 
registers like other architecture? What is the advantage if it is 
scratch registers?

Regards
Bibo Mao
> 
> The leading PT_SIZE bytes of the kernel stack is dedicated for storing
> the struct pt_regs representing the reg file of the thread in the
> userspace.
> 
> Thus we may only read out the userspace T0-T7 value stored when the same
> thread was interrupted or trapped last time, or 0 (if the thread was
> never interrupted or trapped before).
> 
> And it's impossible to read some data used by the kernel internally, or
> some data of another thread.
> 
> But indeed there is some improvement here.  Zeroing these registers
> seems cleaner than reading out the junk values, and also faster (move
> $t0, $r0 is faster than ld.d $t0, $sp, PT_R12).  Not sure if it's worthy
> to violate Huacai's "keep things simple" aspiration though.
> 


  reply	other threads:[~2024-04-02  3:04 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-15  8:07 [PATCH v7 0/7] LoongArch: Add pv ipi support on LoongArch VM Bibo Mao
2024-03-15  8:07 ` [PATCH v7 1/7] LoongArch/smp: Refine some ipi functions on LoongArch platform Bibo Mao
2024-03-15  8:07 ` [PATCH v7 2/7] LoongArch: KVM: Add hypercall instruction emulation support Bibo Mao
2024-03-15  8:07 ` [PATCH v7 3/7] LoongArch: KVM: Add cpucfg area for kvm hypervisor Bibo Mao
2024-03-23 19:02   ` WANG Xuerui
2024-04-02  1:43     ` maobibo
2024-04-02  2:49       ` Xi Ruoyao
2024-04-02  3:04         ` maobibo [this message]
2024-04-02  3:34         ` maobibo
2024-04-02  5:34           ` Xi Ruoyao
2024-03-15  8:07 ` [PATCH v7 4/7] LoongArch: KVM: Add vcpu search support from physical cpuid Bibo Mao
2024-03-15  8:07 ` [PATCH v7 5/7] LoongArch: KVM: Add pv ipi support on kvm side Bibo Mao
2024-03-15  8:10 ` [PATCH v7 6/7] LoongArch: Add pv ipi support on guest kernel side Bibo Mao
2024-03-15  8:11 ` [PATCH v7 7/7] Documentation: KVM: Add hypercall for LoongArch Bibo Mao
2024-03-23 18:40   ` WANG Xuerui
2024-04-02  1:15     ` maobibo

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=4d35124d-527d-ec1c-1eb1-2d98e9d0da46@loongson.cn \
    --to=maobibo@loongson.cn \
    --cc=chenhuacai@kernel.org \
    --cc=corbet@lwn.net \
    --cc=jgross@suse.com \
    --cc=kernel@xen0n.name \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=loongarch@lists.linux.dev \
    --cc=pbonzini@redhat.com \
    --cc=virtualization@lists.linux.dev \
    --cc=xry111@xry111.site \
    --cc=zhaotianrui@loongson.cn \
    /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®