linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Nicholas Piggin <npiggin@gmail.com>
To: "Michal Suchánek" <msuchanek@suse.de>
Cc: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>,
	linuxppc-dev@lists.ozlabs.org
Subject: Re: [RFC PATCH 23/27] powerpc/64: system call implement the bulk of the logic in C
Date: Wed, 02 Oct 2019 13:10:56 +1000	[thread overview]
Message-ID: <1569985820.7ifh9y8ome.astroid@bobo.none> (raw)
In-Reply-To: <20190923124751.GC18205@kitsune.suse.cz>

Michal Suchánek's on September 23, 2019 10:47 pm:
> On Sun, Sep 15, 2019 at 11:28:09AM +1000, Nicholas Piggin wrote:
>> System call entry and particularly exit code is beyond the limit of what
>> is reasonable to implement in asm.
>> 
>> This conversion moves all conditional branches out of the asm code,
>> except for the case that all GPRs should be restored at exit.
>> 
>> Null syscall test is about 5% faster after this patch, because the exit
>> work is handled under local_irq_disable, and the hard mask and pending
>> interrupt replay is handled after that, which avoids games with MSR.
>> 
>> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
>> 
>> v3:
>> - Fix !KUAP build [mpe]
>> - Fix BookE build/boot [mpe]
>> - Don't trace irqs with MSR[RI]=0
>> - Don't allow syscall_exit_prepare to be ftraced, because function
>>   graph tracing which traces exits barfs after the IRQ state is
>>   prepared for kernel exit.
>> - Fix BE syscall table to use normal function descriptors now that they
>>   are called from C.
>> - Comment syscall_exit_prepare.
> ...
>> -#if defined(CONFIG_VIRT_CPU_ACCOUNTING_NATIVE) && defined(CONFIG_PPC_SPLPAR)
>> -BEGIN_FW_FTR_SECTION
>> -	/* see if there are any DTL entries to process */
>> -	ld	r10,PACALPPACAPTR(r13)	/* get ptr to VPA */
>> -	ld	r11,PACA_DTL_RIDX(r13)	/* get log read index */
>> -	addi	r10,r10,LPPACA_DTLIDX
>> -	LDX_BE	r10,0,r10		/* get log write index */
>> -	cmpd	r11,r10
>> -	beq+	33f
>> -	bl	accumulate_stolen_time
>> -	REST_GPR(0,r1)
>> -	REST_4GPRS(3,r1)
>> -	REST_2GPRS(7,r1)
>> -	addi	r9,r1,STACK_FRAME_OVERHEAD
>> -33:
>> -END_FW_FTR_SECTION_IFSET(FW_FEATURE_SPLPAR)
>> -#endif /* CONFIG_VIRT_CPU_ACCOUNTING_NATIVE && CONFIG_PPC_SPLPAR */
> ...
>> diff --git a/arch/powerpc/kernel/syscall_64.c b/arch/powerpc/kernel/syscall_64.c
>> new file mode 100644
>> index 000000000000..1d2529824588
>> --- /dev/null
>> +++ b/arch/powerpc/kernel/syscall_64.c
>> @@ -0,0 +1,195 @@
>> +#include <linux/err.h>
>> +#include <asm/book3s/64/kup-radix.h>
>> +#include <asm/cputime.h>
>> +#include <asm/hw_irq.h>
>> +#include <asm/kprobes.h>
>> +#include <asm/paca.h>
>> +#include <asm/ptrace.h>
>> +#include <asm/reg.h>
>> +#include <asm/signal.h>
>> +#include <asm/switch_to.h>
>> +#include <asm/syscall.h>
>> +#include <asm/time.h>
>> +
>> +extern void __noreturn tabort_syscall(void);
>> +
>> +typedef long (*syscall_fn)(long, long, long, long, long, long);
>> +
>> +long system_call_exception(long r3, long r4, long r5, long r6, long r7, long r8, unsigned long r0, struct pt_regs *regs)
>> +{
>> +	unsigned long ti_flags;
>> +	syscall_fn f;
>> +
>> +	BUG_ON(!(regs->msr & MSR_PR));
>> +
>> +	if (IS_ENABLED(CONFIG_PPC_TRANSACTIONAL_MEM) &&
>> +			unlikely(regs->msr & MSR_TS_T))
>> +		tabort_syscall();
>> +
>> +	account_cpu_user_entry();
>> +
>> +#ifdef CONFIG_PPC_SPLPAR
>> +	if (IS_ENABLED(CONFIG_VIRT_CPU_ACCOUNTING_NATIVE) &&
>> +			firmware_has_feature(FW_FEATURE_SPLPAR)) {
>> +		struct lppaca *lp = get_lppaca();
>> +
>> +		if (unlikely(local_paca->dtl_ridx != lp->dtl_idx))
> 
> sparse complains about this, and in time.c this it converted like this:
> if (unlikely(local_paca->dtl_ridx != be64_to_cpu(lp->dtl_idx)))
> The removed code has a LDX_BE there so there should be some conversion
> involved, right?

Ah yes, thanks good catch.

Thanks,
Nick

  reply	other threads:[~2019-10-02  3:13 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-15  1:27 [RFC PATCH 00/27] current interrupt series plus scv syscall Nicholas Piggin
2019-09-15  1:27 ` [RFC PATCH 01/27] powerpc/64s/exception: Introduce INT_DEFINE parameter block for code generation Nicholas Piggin
2019-09-15  1:27 ` [RFC PATCH 02/27] powerpc/64s/exception: Add GEN_COMMON macro that uses INT_DEFINE parameters Nicholas Piggin
2019-09-15  1:27 ` [RFC PATCH 03/27] powerpc/64s/exception: Add GEN_KVM " Nicholas Piggin
2019-09-15  1:27 ` [RFC PATCH 04/27] powerpc/64s/exception: Expand EXC_COMMON and EXC_COMMON_ASYNC macros Nicholas Piggin
2019-09-15  1:27 ` [RFC PATCH 05/27] powerpc/64s/exception: Move all interrupt handlers to new style code gen macros Nicholas Piggin
2019-09-15  1:27 ` [RFC PATCH 06/27] powerpc/64s/exception: Remove old INT_ENTRY macro Nicholas Piggin
2019-09-15  1:27 ` [RFC PATCH 07/27] powerpc/64s/exception: Remove old INT_COMMON macro Nicholas Piggin
2019-09-15  1:27 ` [RFC PATCH 08/27] powerpc/64s/exception: Remove old INT_KVM_HANDLER Nicholas Piggin
2019-09-15  1:27 ` [RFC PATCH 09/27] powerpc/64s/exception: Add ISIDE option Nicholas Piggin
2019-09-15  1:27 ` [RFC PATCH 10/27] powerpc/64s/exception: move real->virt switch into the common handler Nicholas Piggin
2019-09-15  1:27 ` [RFC PATCH 11/27] powerpc/64s/exception: move soft-mask test to common code Nicholas Piggin
2019-09-15  1:27 ` [RFC PATCH 12/27] powerpc/64s/exception: move KVM " Nicholas Piggin
2019-09-15  1:27 ` [RFC PATCH 13/27] powerpc/64s/exception: remove confusing IEARLY option Nicholas Piggin
2019-09-15  1:28 ` [RFC PATCH 14/27] powerpc/64s/exception: remove the SPR saving patch code macros Nicholas Piggin
2019-09-15  1:28 ` [RFC PATCH 15/27] powerpc/64s/exception: trim unused arguments from KVMTEST macro Nicholas Piggin
2019-09-15  1:28 ` [RFC PATCH 16/27] powerpc/64s/exception: hdecrementer avoid touching the stack Nicholas Piggin
2019-09-15  1:28 ` [RFC PATCH 17/27] powerpc/64s/exception: re-inline some handlers Nicholas Piggin
2019-09-15  1:28 ` [RFC PATCH 18/27] powerpc/64s/exception: Clean up SRR specifiers Nicholas Piggin
2019-09-15  1:28 ` [RFC PATCH 19/27] powerpc/64s/exception: add more comments for interrupt handlers Nicholas Piggin
2019-09-15  1:28 ` [RFC PATCH 20/27] powerpc/64s/exception: only test KVM in SRR interrupts when PR KVM is supported Nicholas Piggin
2019-09-15  1:28 ` [RFC PATCH 21/27] powerpc/64s/exception: soft nmi interrupt should not use ret_from_except Nicholas Piggin
2019-09-15  1:28 ` [RFC PATCH 22/27] powerpc/64: system call remove non-volatile GPR save optimisation Nicholas Piggin
2019-09-15  1:28 ` [RFC PATCH 23/27] powerpc/64: system call implement the bulk of the logic in C Nicholas Piggin
2019-10-02  8:21   ` Michal Suchánek
2019-10-02  3:10     ` Nicholas Piggin [this message]
2019-09-15  1:28 ` [RFC PATCH 24/27] powerpc/64s: interrupt return " Nicholas Piggin
2019-10-02  8:20   ` Michal Suchánek
2019-09-15  1:28 ` [RFC PATCH 25/27] powerpc/64s/exception: remove lite interrupt return Nicholas Piggin
2019-09-15  1:28 ` [RFC PATCH 26/27] powerpc/64s/exception: treat NIA below __end_interrupts as soft-masked Nicholas Piggin
2019-09-15  1:28 ` [RFC PATCH 27/27] powerpc/64s: system call support for scv/rfscv instructions Nicholas Piggin
2019-10-02  8:21   ` Michal Suchánek
2019-10-02  8:20 ` [RFC PATCH 00/27] current interrupt series plus scv syscall Michal Suchánek
2019-10-02  3:13   ` Nicholas Piggin
2019-10-30 12:55     ` Michal Suchánek

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=1569985820.7ifh9y8ome.astroid@bobo.none \
    --to=npiggin@gmail.com \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=msuchanek@suse.de \
    --cc=tuliom@linux.ibm.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;
as well as URLs for NNTP newsgroup(s).