From: Nicholas Piggin <npiggin@gmail.com>
To: Christophe LEROY <christophe.leroy@c-s.fr>
Cc: linux-kernel@vger.kernel.org, Paul Mackerras <paulus@samba.org>,
aneesh.kumar@linux.vnet.ibm.com, linuxppc-dev@lists.ozlabs.org
Subject: Re: [RFC PATCH v3 3/7] powerpc: Activate CONFIG_THREAD_INFO_IN_TASK
Date: Wed, 3 Oct 2018 15:52:43 +1000 [thread overview]
Message-ID: <20181003155243.70806497@roar.ozlabs.ibm.com> (raw)
In-Reply-To: <c1b9f2db-ebca-4a2d-4f91-2dce84da31f2@c-s.fr>
On Wed, 3 Oct 2018 07:47:05 +0200
Christophe LEROY <christophe.leroy@c-s.fr> wrote:
> Le 03/10/2018 à 07:30, Nicholas Piggin a écrit :
> > On Mon, 1 Oct 2018 12:30:23 +0000 (UTC)
> > Christophe Leroy <christophe.leroy@c-s.fr> wrote:
> >
> >> This patch activates CONFIG_THREAD_INFO_IN_TASK which
> >> moves the thread_info into task_struct.
> >>
> >> Moving thread_info into task_struct has the following advantages:
> >> - It protects thread_info from corruption in the case of stack
> >> overflows.
> >> - Its address is harder to determine if stack addresses are
> >> leaked, making a number of attacks more difficult.
> >>
> >> This has the following consequences:
> >> - thread_info is now located at the top of task_struct.
> >
> > "top"... I got confused for a minute thinking high address and
> > wondering how you can change CURRENT_THREAD_INFO just to point
> > to current :)
>
> Would 'beginning' be less confusing ?
Yes, good idea.
> >> @@ -83,7 +83,13 @@ int is_cpu_dead(unsigned int cpu);
> >> /* 32-bit */
> >> extern int smp_hw_index[];
> >>
> >> -#define raw_smp_processor_id() (current_thread_info()->cpu)
> >> +/*
> >> + * This is particularly ugly: it appears we can't actually get the definition
> >> + * of task_struct here, but we need access to the CPU this task is running on.
> >> + * Instead of using task_struct we're using _TASK_CPU which is extracted from
> >> + * asm-offsets.h by kbuild to get the current processor ID.
> >> + */
> >> +#define raw_smp_processor_id() (*(unsigned int*)((void*)current + _TASK_CPU))
> >
> > This is clever but yes ugly. Can't you include asm-offsets.h? riscv
> > seems to.
>
> riscv has a clean asm-offsets.h . Our's defines constant with the same
> name as those defined in other headers which are included in C files. So
> including asm-offsets in C files does create conflicts like:
>
> ./include/generated/asm-offsets.h:71:0: warning: "TASK_SIZE" redefined
> #define TASK_SIZE -2147483648 /* TASK_SIZE */
> ./arch/powerpc/include/asm/processor.h:95:0: note: this is the location
> of the previous definition
> #define TASK_SIZE (CONFIG_TASK_SIZE)
>
> ./include/generated/asm-offsets.h:98:0: warning: "NSEC_PER_SEC" redefined
> #define NSEC_PER_SEC 1000000000 /* NSEC_PER_SEC */
> ./include/linux/time64.h:36:0: note: this is the location of the
> previous definition
> #define NSEC_PER_SEC 1000000000L
>
> ./arch/powerpc/include/asm/nohash/32/pgtable.h:34:0: warning:
> "PGD_TABLE_SIZE" redefined
> #define PGD_TABLE_SIZE (sizeof(pgd_t) << PGD_INDEX_SIZE)
> ./include/generated/asm-offsets.h:101:0: note: this is the location of
> the previous definition
> #define PGD_TABLE_SIZE 256 /* PGD_TABLE_SIZE */
>
> ...
Okay.
>
> In v2, I had a patch to fix those redundancies
> (https://patchwork.ozlabs.org/patch/974363/) but I found it unconvenient.
Because of merge conflicts, or you did not like the new names?
Thanks,
Nick
next prev parent reply other threads:[~2018-10-03 5:56 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-01 12:30 [RFC PATCH v3 0/7] powerpc: Switch to CONFIG_THREAD_INFO_IN_TASK Christophe Leroy
2018-10-01 12:30 ` [RFC PATCH v3 1/7] book3s/64: avoid circular header inclusion in mmu-hash.h Christophe Leroy
2018-10-03 4:24 ` Nicholas Piggin
2018-10-04 8:20 ` Christophe LEROY
2018-10-04 8:23 ` Aneesh Kumar K.V
2018-10-04 8:32 ` Christophe LEROY
2018-10-01 12:30 ` [RFC PATCH v3 2/7] powerpc: Prepare for moving thread_info into task_struct Christophe Leroy
2018-10-03 5:02 ` Nicholas Piggin
2018-10-03 5:49 ` Christophe LEROY
2018-10-03 5:57 ` Nicholas Piggin
2018-10-04 14:29 ` Christophe LEROY
2018-10-01 12:30 ` [RFC PATCH v3 3/7] powerpc: Activate CONFIG_THREAD_INFO_IN_TASK Christophe Leroy
2018-10-03 5:30 ` Nicholas Piggin
2018-10-03 5:47 ` Christophe LEROY
2018-10-03 5:52 ` Nicholas Piggin [this message]
2018-10-03 6:04 ` Christophe LEROY
2018-10-03 6:23 ` Nicholas Piggin
2018-10-01 12:30 ` [RFC PATCH v3 4/7] powerpc: regain entire stack space Christophe Leroy
2018-10-03 5:34 ` Nicholas Piggin
2018-10-03 5:52 ` Christophe LEROY
2018-10-03 6:30 ` Nicholas Piggin
2018-10-03 6:45 ` Christophe LEROY
2018-10-03 7:07 ` Nicholas Piggin
2018-10-03 9:30 ` Christophe LEROY
2018-10-01 12:30 ` [RFC PATCH v3 5/7] powerpc: 'current_set' is now a table of task_struct pointers Christophe Leroy
2018-10-03 5:41 ` Nicholas Piggin
2018-10-03 6:00 ` Christophe LEROY
2018-10-03 6:09 ` Nicholas Piggin
2018-10-01 12:30 ` [RFC PATCH v3 6/7] powerpc/32: Remove CURRENT_THREAD_INFO and rename TI_CPU Christophe Leroy
2018-10-01 12:30 ` [RFC PATCH v3 7/7] powerpc/64: Modify CURRENT_THREAD_INFO() Christophe Leroy
2018-10-03 5:44 ` Nicholas Piggin
2018-10-03 6:01 ` Christophe LEROY
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=20181003155243.70806497@roar.ozlabs.ibm.com \
--to=npiggin@gmail.com \
--cc=aneesh.kumar@linux.vnet.ibm.com \
--cc=christophe.leroy@c-s.fr \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=paulus@samba.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;
as well as URLs for NNTP newsgroup(s).