* Re: [PATCH 13/26] ppc: Convert mmu context allocation to new IDA API
From: Aneesh Kumar K.V @ 2018-06-22 5:47 UTC (permalink / raw)
To: Nicholas Piggin, Matthew Wilcox
Cc: Ram Pai, linux-kernel, Paul Mackerras, Thiago Jung Bauermann,
linuxppc-dev
In-Reply-To: <20180622121511.00ae9d00@roar.ozlabs.ibm.com>
Nicholas Piggin <npiggin@gmail.com> writes:
> On Thu, 21 Jun 2018 14:28:22 -0700
> Matthew Wilcox <willy@infradead.org> wrote:
>
>> ida_alloc_range is the perfect fit for this use case. Eliminates
>> a custom spinlock, a call to ida_pre_get and a local check for the
>> allocated ID exceeding a maximum.
>>
>> Signed-off-by: Matthew Wilcox <willy@infradead.org>
>> ---
>> arch/powerpc/mm/mmu_context_book3s64.c | 44 +++-----------------------
>> 1 file changed, 4 insertions(+), 40 deletions(-)
>>
>> diff --git a/arch/powerpc/mm/mmu_context_book3s64.c b/arch/powerpc/mm/mmu_context_book3s64.c
>> index f3d4b4a0e561..5a0cf2cc8ba0 100644
>> --- a/arch/powerpc/mm/mmu_context_book3s64.c
>> +++ b/arch/powerpc/mm/mmu_context_book3s64.c
>> @@ -26,48 +26,16 @@
>> #include <asm/mmu_context.h>
>> #include <asm/pgalloc.h>
>>
>> -static DEFINE_SPINLOCK(mmu_context_lock);
>> static DEFINE_IDA(mmu_context_ida);
>>
>> static int alloc_context_id(int min_id, int max_id)
>> {
>> - int index, err;
>> -
>> -again:
>> - if (!ida_pre_get(&mmu_context_ida, GFP_KERNEL))
>> - return -ENOMEM;
>> -
>> - spin_lock(&mmu_context_lock);
>> - err = ida_get_new_above(&mmu_context_ida, min_id, &index);
>> - spin_unlock(&mmu_context_lock);
>> -
>> - if (err == -EAGAIN)
>> - goto again;
>> - else if (err)
>> - return err;
>> -
>> - if (index > max_id) {
>> - spin_lock(&mmu_context_lock);
>> - ida_remove(&mmu_context_ida, index);
>> - spin_unlock(&mmu_context_lock);
>> - return -ENOMEM;
>> - }
>> -
>> - return index;
>> + return ida_alloc_range(&mmu_context_ida, min_id, max_id, GFP_KERNEL);
>> }
>>
>> void hash__reserve_context_id(int id)
>> {
>> - int rc, result = 0;
>> -
>> - do {
>> - if (!ida_pre_get(&mmu_context_ida, GFP_KERNEL))
>> - break;
>> -
>> - spin_lock(&mmu_context_lock);
>> - rc = ida_get_new_above(&mmu_context_ida, id, &result);
>> - spin_unlock(&mmu_context_lock);
>> - } while (rc == -EAGAIN);
>> + int result = ida_alloc_range(&mmu_context_ida, id, id, GFP_KERNEL);
>>
>> WARN(result != id, "mmu: Failed to reserve context id %d (rc %d)\n", id, result);
>> }
>> @@ -172,9 +140,7 @@ int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
>>
>> void __destroy_context(int context_id)
>> {
>> - spin_lock(&mmu_context_lock);
>> - ida_remove(&mmu_context_ida, context_id);
>> - spin_unlock(&mmu_context_lock);
>> + ida_free(&mmu_context_ida, context_id);
>> }
>> EXPORT_SYMBOL_GPL(__destroy_context);
>>
>> @@ -182,13 +148,11 @@ static void destroy_contexts(mm_context_t *ctx)
>> {
>> int index, context_id;
>>
>> - spin_lock(&mmu_context_lock);
>> for (index = 0; index < ARRAY_SIZE(ctx->extended_id); index++) {
>> context_id = ctx->extended_id[index];
>> if (context_id)
>> - ida_remove(&mmu_context_ida, context_id);
>> + ida_free(&mmu_context_ida, context_id);
>> }
>> - spin_unlock(&mmu_context_lock);
>> }
>>
>> static void pte_frag_destroy(void *pte_frag)
>
> This hunk should be okay because the mmu_context_lock does not protect
> the extended_id array, right Aneesh?
Yes. This is called at process exit, so we should not find parallel
calls. On the allocation side, we are protected by mmap_sem. We do
allocate extended_id when doing mmap.
-aneesh
^ permalink raw reply
* Re: [PATCH 13/26] ppc: Convert mmu context allocation to new IDA API
From: Aneesh Kumar K.V @ 2018-06-22 5:47 UTC (permalink / raw)
To: Matthew Wilcox, Nicholas Piggin
Cc: linux-kernel, Benjamin Herrenschmidt, Paul Mackerras,
Michael Ellerman, Thiago Jung Bauermann, Ram Pai, linuxppc-dev
In-Reply-To: <20180622043815.GA31255@bombadil.infradead.org>
Matthew Wilcox <willy@infradead.org> writes:
> this situation from occurring (like, oh i don't know, this function only
> being called on process exit, so implicitly only called once per context).
>
That is correct.
^ permalink raw reply
* [PATCH 2/2] powerpc: Document issues with TM on POWER9
From: Michael Neuling @ 2018-06-22 6:14 UTC (permalink / raw)
To: mpe; +Cc: linuxppc-dev, mikey
In-Reply-To: <20180622061452.19016-1-mikey@neuling.org>
Signed-off-by: Michael Neuling <mikey@neuling.org>
---
.../powerpc/transactional_memory.txt | 44 +++++++++++++++++++
1 file changed, 44 insertions(+)
diff --git a/Documentation/powerpc/transactional_memory.txt b/Documentation/powerpc/transactional_memory.txt
index e32fdbb4c9..b254eab517 100644
--- a/Documentation/powerpc/transactional_memory.txt
+++ b/Documentation/powerpc/transactional_memory.txt
@@ -198,3 +198,47 @@ presented). The transaction cannot then be continued and will take the failure
handler route. Furthermore, the transactional 2nd register state will be
inaccessible. GDB can currently be used on programs using TM, but not sensibly
in parts within transactions.
+
+POWER9
+======
+
+TM on POWER9 has issues with storing the complete register state. This
+is described in this commit:
+
+ commit 4bb3c7a0208fc13ca70598efd109901a7cd45ae7
+ Author: Paul Mackerras <paulus@ozlabs.org>
+ Date: Wed Mar 21 21:32:01 2018 +1100
+ KVM: PPC: Book3S HV: Work around transactional memory bugs in POWER9
+
+To account for this different POWER9 chips have TM enabled in
+different ways.
+
+On POWER9N DD2.01 and below, TM is disabled. ie
+HWCAP2[PPC_FEATURE2_HTM] is not set.
+
+On POWER9N DD2.1 TM is configured by firmware to always abort a
+transaction when tm suspend occurs. So tsuspend will cause a
+transaction to be aborted and rolled back. Kernel exceptions will also
+cause the transaction to be aborted and rolled back and the exception
+will not occur. If userspace constructs a sigcontext that enables TM
+suspend, the sigcontext will be rejected by the kernel. This mode is
+advertised to users with HWCAP2[PPC_FEATURE2_HTM_NO_SUSPEND] set.
+HWCAP2[PPC_FEATURE2_HTM] is not set in this mode.
+
+On POWER9N DD2.2 and above, KVM and POWERVM emulate TM for guests (as
+descibed in commit 4bb3c7a0208f), hence TM is enabled for guests
+ie. HWCAP2[PPC_FEATURE2_HTM] is set for guest userspace. Guests that
+makes heavy use of TM suspend (tsuspend or kernel suspend) will result
+in traps into the hypervisor and hence will suffer a performance
+degredation. Host userspace has TM disabled
+ie. HWCAP2[PPC_FEATURE2_HTM] is not set. (although we make enable it
+at some point in the future if we bring the emulation into host
+userspace context switching).
+
+POWER9C DD1.2 and above are only avaliable with POWERNV and hence
+Linux only runs as a guest. On these systems TM is emulated like on
+POWER9N DD2.2.
+
+Guest migration from POWER8 to POWER9 will work with POWER9N DD2.2 and
+POWER9C DD1.2. Since earlier POWER9 processors don't support TM
+emulation, migration from POWER8 to POWER9 is not supported there.
--
2.17.1
^ permalink raw reply related
* [PATCH 1/2] powerpc: Document issues with the DAWR on POWER9
From: Michael Neuling @ 2018-06-22 6:14 UTC (permalink / raw)
To: mpe; +Cc: linuxppc-dev, mikey
Signed-off-by: Michael Neuling <mikey@neuling.org>
---
Documentation/powerpc/DAWR-POWER9.txt | 58 +++++++++++++++++++++++++++
1 file changed, 58 insertions(+)
create mode 100644 Documentation/powerpc/DAWR-POWER9.txt
diff --git a/Documentation/powerpc/DAWR-POWER9.txt b/Documentation/powerpc/DAWR-POWER9.txt
new file mode 100644
index 0000000000..cc6e69b69b
--- /dev/null
+++ b/Documentation/powerpc/DAWR-POWER9.txt
@@ -0,0 +1,58 @@
+DAWR issues on POWER9
+============================
+
+On POWER9 the DAWR can cause a checkstop if it points to cache
+inhibited (CI) memory. Currently Linux has no way to disinguish CI
+memory when configuring the DAWR, so (for now) the DAWR is disabled by
+this commit:
+
+ commit 9654153158d3e0684a1bdb76dbababdb7111d5a0
+ Author: Michael Neuling <mikey@neuling.org>
+ Date: Tue Mar 27 15:37:24 2018 +1100
+ powerpc: Disable DAWR in the base POWER9 CPU features
+
+Technical Details:
+============================
+
+DAWR has 6 different ways of being set.
+1) ptrace
+2) h_set_mode(DAWR)
+3) h_set_dabr()
+4) kvmppc_set_one_reg()
+5) xmon
+
+For ptrace, we now advertise zero breakpoints on POWER9 via the
+PPC_PTRACE_GETHWDBGINFO call. This results in GDB falling back to
+software emulation of the watchpoint (which is slow).
+
+h_set_mode(DAWR) and h_set_dabr() will now return an error to the
+guest on a POWER9 host. Current Linux guests ignore this error, so
+they will silently not get the DAWR.
+
+kvmppc_set_one_reg() will store the value in the vcpu but won't
+actually set it on POWER9 hardware. This is done so we don't break
+migration from POWER8 to POWER9, at the cost of silently losing the
+DAWR on the migration.
+
+For xmon, the 'bd' command will return an error on P9.
+
+Consequences for users
+============================
+
+For GDB watchpoints (ie 'watch' command) on POWER9 bare metal , GDB
+will accept the command. Unfortunatley since there is no hardware
+support for the watchpoint, GDB will software emulate the watchpoint
+making it run very slowly.
+
+The same will also be true for any guests started on a POWER9
+host. The watchpoint will fail and GDB will fall back to software
+emulation.
+
+If a guest is started on a POWER8 host, GDB will accept the watchpoint
+and configure the hardware to use the DAWR. This will run at full
+speed since it can use the hardware emualation. Unfortnatley if this
+guest is migrated to a POWER9 host, the watchpoint will be lost on the
+POWER9. Loads and stores to the watchpoint locations will not be
+trapped in GDB. The watchpoint is remembered, so if the guest is
+migrated back to the POWER8 host, it will start working again.
+
--
2.17.1
^ permalink raw reply related
* Re: [PATCH 1/2] powerpc: Document issues with the DAWR on POWER9
From: Stewart Smith @ 2018-06-22 7:00 UTC (permalink / raw)
To: Michael Neuling, mpe; +Cc: mikey, linuxppc-dev
In-Reply-To: <20180622061452.19016-1-mikey@neuling.org>
Michael Neuling <mikey@neuling.org> writes:
> Signed-off-by: Michael Neuling <mikey@neuling.org>
> ---
> Documentation/powerpc/DAWR-POWER9.txt | 58 +++++++++++++++++++++++++++
> 1 file changed, 58 insertions(+)
> create mode 100644 Documentation/powerpc/DAWR-POWER9.txt
Acked-by: Stewart Smith <stewart@linux.ibm.com>
--
Stewart Smith
OPAL Architect, IBM.
^ permalink raw reply
* Re: [PATCH 2/2] powerpc: Document issues with TM on POWER9
From: Stewart Smith @ 2018-06-22 7:01 UTC (permalink / raw)
To: Michael Neuling, mpe; +Cc: mikey, linuxppc-dev
In-Reply-To: <20180622061452.19016-2-mikey@neuling.org>
Michael Neuling <mikey@neuling.org> writes:
> +POWER9C DD1.2 and above are only avaliable with POWERNV and hence
PowerVM, not POWERNV
--
Stewart Smith
OPAL Architect, IBM.
^ permalink raw reply
* Re: [PATCH v3] powerpc/32: Remove left over function prototypes
From: Mathieu Malaterre @ 2018-06-22 7:15 UTC (permalink / raw)
To: Michael Ellerman
Cc: Benjamin Herrenschmidt, Paul Mackerras, Nicholas Piggin,
linuxppc-dev, LKML
In-Reply-To: <87602cfkh5.fsf@concordia.ellerman.id.au>
On Thu, Jun 21, 2018 at 1:27 PM Michael Ellerman <mpe@ellerman.id.au> wrote:
>
> Mathieu Malaterre <malat@debian.org> writes:
>
> > In commit 4aea909eeba3 ("powerpc: Add missing prototypes in setup_32.c")
>
> I don't have that commit ^ ?
>
> That might be because I squashed some of your fixes together or something?
I am doing an awful lots of mistakes these days. Indeed you've changed
one of my patch:
https://patchwork.kernel.org/patch/10240997/
This one appeared after a git rebase on my side.
> > diff --git a/arch/powerpc/kernel/setup.h b/arch/powerpc/kernel/setup.h
> > index 35ca309848d7..829ed66f0a40 100644
> > --- a/arch/powerpc/kernel/setup.h
> > +++ b/arch/powerpc/kernel/setup.h
> > @@ -19,9 +19,6 @@ void irqstack_early_init(void);
> > void setup_power_save(void);
> > unsigned long __init early_init(unsigned long dt_ptr);
> > void __init machine_init(u64 dt_ptr);
> > -int __init ppc_setup_l2cr(char *str);
> > -int __init ppc_setup_l3cr(char *str);
> > -int __init ppc_init(void);
> > #else
> > static inline void setup_power_save(void) { };
> > #endif
>
> I have:
>
> #ifdef CONFIG_PPC32
> void setup_power_save(void);
> #else
> static inline void setup_power_save(void) { };
> #endif
Correct.
Sorry for the noise.
>
> cheers
^ permalink raw reply
* Re: [PATCH] ocxl: Fix page fault handler in case of fault on dying process
From: Andrew Donnellan @ 2018-06-21 8:07 UTC (permalink / raw)
To: Frederic Barrat, alastair, linuxppc-dev; +Cc: clombard, vaibhav
In-Reply-To: <20180618121436.20479-1-fbarrat@linux.ibm.com>
On 18/06/18 22:14, Frederic Barrat wrote:
> If a process exits without doing proper cleanup, there's a window
> where an opencapi device can try to access the memory of the dying
> process and may trigger a page fault. That's an expected scenario and
> the ocxl driver holds a reference on the mm_struct of the process
> until the opencapi device is notified of the process exiting.
> However, if mm_users is already at 0, i.e. the address space of the
> process has already been destroyed, the driver shouldn't try resolving
> the page fault, as it will fail, but it can also try accessing already
> freed data.
>
> It is fixed by only calling the bottom half of the page fault handler
> if mm_users is greater than 0 and get a reference on mm_users instead
> of mm_count. Otherwise, we can safely return a translation fault to
> the device, as its associated memory context is being removed. The
> opencapi device will be properly cleaned up shortly after when closing
> the file descriptors.
>
> Fixes: 5ef3166e8a32 ("ocxl: Driver code for 'generic' opencapi devices")
> Cc: stable@vger.kernel.org # v4.16+
> Signed-off-by: Frederic Barrat <fbarrat@linux.ibm.com>
I think I understand what's going on here and it looks right.
Acked-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
--
Andrew Donnellan OzLabs, ADL Canberra
andrew.donnellan@au1.ibm.com IBM Australia Limited
^ permalink raw reply
* Re: [PATCH 2/3] [v2] m68k: mac: use time64_t in RTC handling
From: Arnd Bergmann @ 2018-06-22 8:54 UTC (permalink / raw)
To: Finn Thain
Cc: Paul Mackerras, Michael Ellerman, Geert Uytterhoeven,
Joshua Thompson, Mathieu Malaterre, Benjamin Herrenschmidt,
Greg Ungerer, linux-m68k, linuxppc-dev, Linux Kernel Mailing List,
y2038 Mailman List, Meelis Roos, Andreas Schwab
In-Reply-To: <alpine.LNX.2.21.1806221455570.14@nippy.intranet>
On Fri, Jun 22, 2018 at 7:26 AM, Finn Thain <fthain@telegraphics.com.au> wrote:
> On Tue, 19 Jun 2018, Arnd Bergmann wrote:
>
>> The real-time clock on m68k (and powerpc) mac systems uses an unsigned
>> 32-bit value starting in 1904, which overflows in 2040, about two years
>> later than everyone else, but this gets wrapped around in the Linux code
>> in 2038 already because of the deprecated usage of time_t and/or long in
>> the conversion.
>>
>> Getting rid of the deprecated interfaces makes it work until 2040 as
>> documented, and it could be easily extended by reinterpreting the
>> resulting time64_t as a positive number. For the moment, I'm adding a
>> WARN_ON() that triggers if we encounter a time before 1970 or after 2040
>> (the two are indistinguishable).
>>
>
> I really don't like the WARN_ON(), but I'd prefer to address that in a
> separate patch rather than impede the progress of this patch (or of this
> series, since 3/3 seems to be unrelated).
>
> BTW, have you considered using the same wrap-around test (i.e. YY < 70)
> that we use for the year register in the other RTC chips?
That wrap-around test would have the same effect as the my original
version (aside from the two bugs I now fixed), doing rougly
- return time - RTC_OFFSET;
+ return (u32)(time - RTC_OFFSET);
or some other variation of that will give us an RTC that supports all dates
between 1970 and 2106. I don't think anyone so far had a strong
preference here, so I went with what Mathieu suggested and kept the
original Mac behavior, but added the WARN_ON().
>> This brings it in line with the corresponding code that we have on
>> powerpc macintosh.
>>
>
> Your recent patches to the Mac RTC routines (which are duplicated under
> arch/m68k and arch/powerpc) conflict with my recent patch that
> deduplicates the same code. So I will rebase and resubmit after someone
> merges these fixes.
>
> Apparently the PowerMac routines work now, which is sufficient testing for
> me; the PowerMac routines will get tested on m68k Macs when that code gets
> deduplicated again.
Sorry about introducing that conflict, and thanks for bearing with me on the
rebase. One thing to watch out for (if you haven't noticed already) is that the
powerpc version now depends on rtc_time64_to_tm/rtc_tm_to_time64 which
are only available if CONFIG_RTC_LIB is enabled but simplifies the code a
bit. I did not want to introduce that as a global dependency on m68k which
is rather limited on code size already, but it probably doesn't hurt to require
RTC_LIB on m68k-mac.
Arnd
^ permalink raw reply
* Re: [PATCH v2 02/19] powerpc/powermac: Mark variable x as unused
From: Mathieu Malaterre @ 2018-06-22 9:46 UTC (permalink / raw)
To: Michael Ellerman
Cc: LKML, Christophe LEROY, linuxppc-dev, Paul Mackerras,
Benjamin Herrenschmidt
In-Reply-To: <20180329180922.Horde.Mtq3N9paq5gkMn9QcIUlGQ1@messagerie.si.c-s.fr>
On Thu, Mar 29, 2018 at 6:09 PM LEROY Christophe
<christophe.leroy@c-s.fr> wrote:
>
> Mathieu Malaterre <malat@debian.org> a =C3=A9crit :
>
> > Since the value of x is never intended to be read, remove it. Fix warni=
ng
> > treated as error with W=3D1:
> >
> > arch/powerpc/platforms/powermac/udbg_scc.c:76:9: error: variable
> > =E2=80=98x=E2=80=99 set but not used [-Werror=3Dunused-but-set-variable=
]
> >
> > Suggested-by: Christophe Leroy <christophe.leroy@c-s.fr>
> > Signed-off-by: Mathieu Malaterre <malat@debian.org>
>
> Reviewed-by: Christophe Leroy <christophe.leroy@c-s.fr>
Michael, can you take this one ?
> > ---
> > v2: remove x completely
> >
> > arch/powerpc/platforms/powermac/udbg_scc.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/arch/powerpc/platforms/powermac/udbg_scc.c
> > b/arch/powerpc/platforms/powermac/udbg_scc.c
> > index d83135a9830e..8901973ed683 100644
> > --- a/arch/powerpc/platforms/powermac/udbg_scc.c
> > +++ b/arch/powerpc/platforms/powermac/udbg_scc.c
> > @@ -73,7 +73,7 @@ void udbg_scc_init(int force_scc)
> > struct device_node *stdout =3D NULL, *escc =3D NULL, *macio =3D N=
ULL;
> > struct device_node *ch, *ch_def =3D NULL, *ch_a =3D NULL;
> > const char *path;
> > - int i, x;
> > + int i;
> >
> > escc =3D of_find_node_by_name(NULL, "escc");
> > if (escc =3D=3D NULL)
> > @@ -120,7 +120,7 @@ void udbg_scc_init(int force_scc)
> > mb();
> >
> > for (i =3D 20000; i !=3D 0; --i)
> > - x =3D in_8(sccc);
> > + in_8(sccc);
> > out_8(sccc, 0x09); /* reset A or B side */
> > out_8(sccc, 0xc0);
> >
> > --
> > 2.11.0
>
>
^ permalink raw reply
* Re: [PATCH v3 03/19] powerpc: Move `path` variable inside DEBUG_PROM
From: Mathieu Malaterre @ 2018-06-22 9:48 UTC (permalink / raw)
To: Michael Ellerman
Cc: Christophe LEROY, Benjamin Herrenschmidt, Paul Mackerras,
linuxppc-dev, LKML
In-Reply-To: <20180404200836.27446-1-malat@debian.org>
This one should be ok.
On Wed, Apr 4, 2018 at 10:08 PM Mathieu Malaterre <malat@debian.org> wrote:
>
> Add gcc attribute unused for two variables. Fix warnings treated as error=
s
> with W=3D1:
>
> arch/powerpc/kernel/prom_init.c:1388:8: error: variable =E2=80=98path=
=E2=80=99 set but not used [-Werror=3Dunused-but-set-variable]
>
> Suggested-by: Christophe Leroy <christophe.leroy@c-s.fr>
> Signed-off-by: Mathieu Malaterre <malat@debian.org>
> ---
> v3: really move path within ifdef DEBUG_PROM
> v2: move path within ifdef DEBUG_PROM
>
> arch/powerpc/kernel/prom_init.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_i=
nit.c
> index acf4b2e0530c..223b35acbbdd 100644
> --- a/arch/powerpc/kernel/prom_init.c
> +++ b/arch/powerpc/kernel/prom_init.c
> @@ -603,7 +603,7 @@ static void __init early_cmdline_parse(void)
> const char *opt;
>
> char *p;
> - int l =3D 0;
> + int l __maybe_unused =3D 0;
>
> prom_cmd_line[0] =3D 0;
> p =3D prom_cmd_line;
> @@ -1385,7 +1385,10 @@ static void __init reserve_mem(u64 base, u64 size)
> static void __init prom_init_mem(void)
> {
> phandle node;
> - char *path, type[64];
> +#ifdef DEBUG_PROM
> + char *path;
> +#endif
> + char type[64];
> unsigned int plen;
> cell_t *p, *endp;
> __be32 val;
> @@ -1406,7 +1409,9 @@ static void __init prom_init_mem(void)
> prom_debug("root_size_cells: %x\n", rsc);
>
> prom_debug("scanning memory:\n");
> +#ifdef DEBUG_PROM
> path =3D prom_scratch;
> +#endif
>
> for (node =3D 0; prom_next_node(&node); ) {
> type[0] =3D 0;
> --
> 2.11.0
>
^ permalink raw reply
* Re: [PATCH 16/19] powerpc/powermac: Add missing include of header pmac.h
From: Mathieu Malaterre @ 2018-06-22 9:49 UTC (permalink / raw)
To: Michael Ellerman
Cc: Benjamin Herrenschmidt, Paul Mackerras, linuxppc-dev, LKML,
kvm-ppc
In-Reply-To: <20180322202007.23088-17-malat@debian.org>
This one is also ok.
On Thu, Mar 22, 2018 at 9:21 PM Mathieu Malaterre <malat@debian.org> wrote:
>
> The header `pmac.h` was not included, leading to the following warnings,
> treated as error with W=3D1:
>
> arch/powerpc/platforms/powermac/time.c:69:13: error: no previous protot=
ype for =E2=80=98pmac_time_init=E2=80=99 [-Werror=3Dmissing-prototypes]
> arch/powerpc/platforms/powermac/time.c:207:15: error: no previous proto=
type for =E2=80=98pmac_get_boot_time=E2=80=99 [-Werror=3Dmissing-prototypes=
]
> arch/powerpc/platforms/powermac/time.c:222:6: error: no previous protot=
ype for =E2=80=98pmac_get_rtc_time=E2=80=99 [-Werror=3Dmissing-prototypes]
> arch/powerpc/platforms/powermac/time.c:240:5: error: no previous protot=
ype for =E2=80=98pmac_set_rtc_time=E2=80=99 [-Werror=3Dmissing-prototypes]
> arch/powerpc/platforms/powermac/time.c:259:12: error: no previous proto=
type for =E2=80=98via_calibrate_decr=E2=80=99 [-Werror=3Dmissing-prototypes=
]
> arch/powerpc/platforms/powermac/time.c:311:13: error: no previous proto=
type for =E2=80=98pmac_calibrate_decr=E2=80=99 [-Werror=3Dmissing-prototype=
s]
>
> The function `via_calibrate_decr` was made static to silence a warning.
>
> Signed-off-by: Mathieu Malaterre <malat@debian.org>
> ---
> arch/powerpc/platforms/powermac/time.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/arch/powerpc/platforms/powermac/time.c b/arch/powerpc/platfo=
rms/powermac/time.c
> index 274af6fa388e..5cc6fa40fcc4 100644
> --- a/arch/powerpc/platforms/powermac/time.c
> +++ b/arch/powerpc/platforms/powermac/time.c
> @@ -34,6 +34,8 @@
> #include <asm/nvram.h>
> #include <asm/smu.h>
>
> +#include "pmac.h"
> +
> #undef DEBUG
>
> #ifdef DEBUG
> @@ -256,7 +258,7 @@ int pmac_set_rtc_time(struct rtc_time *tm)
> * Calibrate the decrementer register using VIA timer 1.
> * This is used both on powermacs and CHRP machines.
> */
> -int __init via_calibrate_decr(void)
> +static int __init via_calibrate_decr(void)
> {
> struct device_node *vias;
> volatile unsigned char __iomem *via;
> --
> 2.11.0
>
^ permalink raw reply
* Re: [PATCH v2 07/19] powerpc/powermac: Make some functions static
From: Mathieu Malaterre @ 2018-06-22 11:29 UTC (permalink / raw)
To: Michael Ellerman
Cc: Christophe LEROY, Benjamin Herrenschmidt, Paul Mackerras,
linuxppc-dev, LKML
In-Reply-To: <20180328193935.1338-1-malat@debian.org>
This one should also be good to go.
On Wed, Mar 28, 2018 at 9:39 PM Mathieu Malaterre <malat@debian.org> wrote:
>
> These functions can all be static, make it so. Fix warnings treated as
> errors with W=3D1:
>
> arch/powerpc/platforms/powermac/pci.c:1022:6: error: no previous protot=
ype for =E2=80=98pmac_pci_fixup_ohci=E2=80=99 [-Werror=3Dmissing-prototypes=
]
> arch/powerpc/platforms/powermac/pci.c:1057:6: error: no previous protot=
ype for =E2=80=98pmac_pci_fixup_cardbus=E2=80=99 [-Werror=3Dmissing-prototy=
pes]
> arch/powerpc/platforms/powermac/pci.c:1094:6: error: no previous protot=
ype for =E2=80=98pmac_pci_fixup_pciata=E2=80=99 [-Werror=3Dmissing-prototyp=
es]
>
> Remove has_address declaration and assignment since not used. Also add gc=
c
> attribute unused to fix a warning treated as error with W=3D1:
>
> arch/powerpc/platforms/powermac/pci.c:784:19: error: variable =E2=80=98=
has_address=E2=80=99 set but not used [-Werror=3Dunused-but-set-variable]
> arch/powerpc/platforms/powermac/pci.c:907:22: error: variable =E2=80=98=
ht=E2=80=99 set but not used [-Werror=3Dunused-but-set-variable]
>
> Suggested-by: Christophe Leroy <christophe.leroy@c-s.fr>
> Signed-off-by: Mathieu Malaterre <malat@debian.org>
> ---
> v2: remove has_address variable since not used
> arch/powerpc/platforms/powermac/pci.c | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/arch/powerpc/platforms/powermac/pci.c b/arch/powerpc/platfor=
ms/powermac/pci.c
> index 0b8174a79993..67c497093e0a 100644
> --- a/arch/powerpc/platforms/powermac/pci.c
> +++ b/arch/powerpc/platforms/powermac/pci.c
> @@ -781,12 +781,12 @@ static int __init pmac_add_bridge(struct device_nod=
e *dev)
> struct resource rsrc;
> char *disp_name;
> const int *bus_range;
> - int primary =3D 1, has_address =3D 0;
> + int primary =3D 1;
>
> DBG("Adding PCI host bridge %pOF\n", dev);
>
> /* Fetch host bridge registers address */
> - has_address =3D (of_address_to_resource(dev, 0, &rsrc) =3D=3D 0);
> + of_address_to_resource(dev, 0, &rsrc);
>
> /* Get bus range if any */
> bus_range =3D of_get_property(dev, "bus-range", &len);
> @@ -904,7 +904,7 @@ static int pmac_pci_root_bridge_prepare(struct pci_ho=
st_bridge *bridge)
> void __init pmac_pci_init(void)
> {
> struct device_node *np, *root;
> - struct device_node *ht =3D NULL;
> + struct device_node *ht __maybe_unused =3D NULL;
>
> pci_set_flags(PCI_CAN_SKIP_ISA_ALIGN);
>
> @@ -1019,7 +1019,7 @@ static bool pmac_pci_enable_device_hook(struct pci_=
dev *dev)
> return true;
> }
>
> -void pmac_pci_fixup_ohci(struct pci_dev *dev)
> +static void pmac_pci_fixup_ohci(struct pci_dev *dev)
> {
> struct device_node *node =3D pci_device_to_OF_node(dev);
>
> @@ -1054,7 +1054,7 @@ void __init pmac_pcibios_after_init(void)
> }
> }
>
> -void pmac_pci_fixup_cardbus(struct pci_dev* dev)
> +static void pmac_pci_fixup_cardbus(struct pci_dev *dev)
> {
> if (!machine_is(powermac))
> return;
> @@ -1091,7 +1091,7 @@ void pmac_pci_fixup_cardbus(struct pci_dev* dev)
>
> DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_TI, PCI_ANY_ID, pmac_pci_fixup_car=
dbus);
>
> -void pmac_pci_fixup_pciata(struct pci_dev* dev)
> +static void pmac_pci_fixup_pciata(struct pci_dev *dev)
> {
> u8 progif =3D 0;
>
> --
> 2.11.0
>
^ permalink raw reply
* [PATCH] powerpc/mm: fix missing prototypes in slice.c
From: Christophe Leroy @ 2018-06-22 13:49 UTC (permalink / raw)
To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman, malat,
aneesh.kumar
Cc: linux-kernel, linuxppc-dev
This patch fixes the following warnings (obtained with make W=1).
arch/powerpc/mm/slice.c: At top level:
arch/powerpc/mm/slice.c:682:15: error: no previous prototype for 'arch_get_unmapped_area' [-Werror=missing-prototypes]
unsigned long arch_get_unmapped_area(struct file *filp,
^
arch/powerpc/mm/slice.c:692:15: error: no previous prototype for 'arch_get_unmapped_area_topdown' [-Werror=missing-prototypes]
unsigned long arch_get_unmapped_area_topdown(struct file *filp,
^
Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
---
arch/powerpc/mm/slice.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/powerpc/mm/slice.c b/arch/powerpc/mm/slice.c
index 205fe557ca10..9530c6db406a 100644
--- a/arch/powerpc/mm/slice.c
+++ b/arch/powerpc/mm/slice.c
@@ -31,6 +31,7 @@
#include <linux/spinlock.h>
#include <linux/export.h>
#include <linux/hugetlb.h>
+#include <linux/sched/mm.h>
#include <asm/mman.h>
#include <asm/mmu.h>
#include <asm/copro.h>
--
2.13.3
^ permalink raw reply related
* [PATCH] powerpc/mm: fix always true/false warning in slice.c
From: Christophe Leroy @ 2018-06-22 13:49 UTC (permalink / raw)
To: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman, malat,
aneesh.kumar
Cc: linux-kernel, linuxppc-dev
This patch fixes the following warnings (obtained with make W=1).
arch/powerpc/mm/slice.c: In function 'slice_range_to_mask':
arch/powerpc/mm/slice.c:73:12: error: comparison is always true due to limited range of data type [-Werror=type-limits]
if (start < SLICE_LOW_TOP) {
^
arch/powerpc/mm/slice.c:81:20: error: comparison is always false due to limited range of data type [-Werror=type-limits]
if ((start + len) > SLICE_LOW_TOP) {
^
arch/powerpc/mm/slice.c: In function 'slice_mask_for_free':
arch/powerpc/mm/slice.c:136:17: error: comparison is always true due to limited range of data type [-Werror=type-limits]
if (high_limit <= SLICE_LOW_TOP)
^
arch/powerpc/mm/slice.c: In function 'slice_check_range_fits':
arch/powerpc/mm/slice.c:185:12: error: comparison is always true due to limited range of data type [-Werror=type-limits]
if (start < SLICE_LOW_TOP) {
^
arch/powerpc/mm/slice.c:195:39: error: comparison is always false due to limited range of data type [-Werror=type-limits]
if (SLICE_NUM_HIGH && ((start + len) > SLICE_LOW_TOP)) {
^
arch/powerpc/mm/slice.c: In function 'slice_scan_available':
arch/powerpc/mm/slice.c:306:11: error: comparison is always true due to limited range of data type [-Werror=type-limits]
if (addr < SLICE_LOW_TOP) {
^
arch/powerpc/mm/slice.c: In function 'get_slice_psize':
arch/powerpc/mm/slice.c:709:11: error: comparison is always true due to limited range of data type [-Werror=type-limits]
if (addr < SLICE_LOW_TOP) {
^
Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
---
arch/powerpc/mm/slice.c | 21 ++++++++++++++-------
1 file changed, 14 insertions(+), 7 deletions(-)
diff --git a/arch/powerpc/mm/slice.c b/arch/powerpc/mm/slice.c
index 9530c6db406a..17c57760e06c 100644
--- a/arch/powerpc/mm/slice.c
+++ b/arch/powerpc/mm/slice.c
@@ -62,6 +62,13 @@ static void slice_print_mask(const char *label, const struct slice_mask *mask) {
#endif
+static inline bool slice_addr_is_low(unsigned long addr)
+{
+ u64 tmp = (u64)addr;
+
+ return tmp < SLICE_LOW_TOP;
+}
+
static void slice_range_to_mask(unsigned long start, unsigned long len,
struct slice_mask *ret)
{
@@ -71,7 +78,7 @@ static void slice_range_to_mask(unsigned long start, unsigned long len,
if (SLICE_NUM_HIGH)
bitmap_zero(ret->high_slices, SLICE_NUM_HIGH);
- if (start < SLICE_LOW_TOP) {
+ if (slice_addr_is_low(start)) {
unsigned long mend = min(end,
(unsigned long)(SLICE_LOW_TOP - 1));
@@ -79,7 +86,7 @@ static void slice_range_to_mask(unsigned long start, unsigned long len,
- (1u << GET_LOW_SLICE_INDEX(start));
}
- if ((start + len) > SLICE_LOW_TOP) {
+ if (!slice_addr_is_low(end)) {
unsigned long start_index = GET_HIGH_SLICE_INDEX(start);
unsigned long align_end = ALIGN(end, (1UL << SLICE_HIGH_SHIFT));
unsigned long count = GET_HIGH_SLICE_INDEX(align_end) - start_index;
@@ -134,7 +141,7 @@ static void slice_mask_for_free(struct mm_struct *mm, struct slice_mask *ret,
if (!slice_low_has_vma(mm, i))
ret->low_slices |= 1u << i;
- if (high_limit <= SLICE_LOW_TOP)
+ if (slice_addr_is_low(high_limit - 1))
return;
for (i = 0; i < GET_HIGH_SLICE_INDEX(high_limit); i++)
@@ -183,7 +190,7 @@ static bool slice_check_range_fits(struct mm_struct *mm,
unsigned long end = start + len - 1;
u64 low_slices = 0;
- if (start < SLICE_LOW_TOP) {
+ if (slice_addr_is_low(start)) {
unsigned long mend = min(end,
(unsigned long)(SLICE_LOW_TOP - 1));
@@ -193,7 +200,7 @@ static bool slice_check_range_fits(struct mm_struct *mm,
if ((low_slices & available->low_slices) != low_slices)
return false;
- if (SLICE_NUM_HIGH && ((start + len) > SLICE_LOW_TOP)) {
+ if (SLICE_NUM_HIGH && !slice_addr_is_low(end)) {
unsigned long start_index = GET_HIGH_SLICE_INDEX(start);
unsigned long align_end = ALIGN(end, (1UL << SLICE_HIGH_SHIFT));
unsigned long count = GET_HIGH_SLICE_INDEX(align_end) - start_index;
@@ -304,7 +311,7 @@ static bool slice_scan_available(unsigned long addr,
int end, unsigned long *boundary_addr)
{
unsigned long slice;
- if (addr < SLICE_LOW_TOP) {
+ if (slice_addr_is_low(addr)) {
slice = GET_LOW_SLICE_INDEX(addr);
*boundary_addr = (slice + end) << SLICE_LOW_SHIFT;
return !!(available->low_slices & (1u << slice));
@@ -707,7 +714,7 @@ unsigned int get_slice_psize(struct mm_struct *mm, unsigned long addr)
VM_BUG_ON(radix_enabled());
- if (addr < SLICE_LOW_TOP) {
+ if (slice_addr_is_low(addr)) {
psizes = mm->context.low_slices_psize;
index = GET_LOW_SLICE_INDEX(addr);
} else {
--
2.13.3
^ permalink raw reply related
* Re: [PATCH] selftests/powerpc: Fix strncpy usage
From: Breno Leitao @ 2018-06-22 14:43 UTC (permalink / raw)
To: Segher Boessenkool; +Cc: linuxppc-dev, Anshuman Khandual
In-Reply-To: <20180621231856.GO16221@gate.crashing.org>
Hi Segher,
On 06/21/2018 08:18 PM, Segher Boessenkool wrote:
> On Wed, Jun 20, 2018 at 07:51:11PM -0300, Breno Leitao wrote:
>> - strncpy(prog, argv[0], strlen(argv[0]));
>> + strncpy(prog, argv[0], sizeof(prog) - 1);
>
> strncpy(prog, argv[0], sizeof prog);
> if (prog[sizeof prog - 1])
> scream_bloody_murder();
>
> Silently using the wrong data is a worse habit than not checking for
> overflows ;-)
Completely agree! Thanks for bringing this up.
If you don't mind, I would solve this problem slightly different, as it seems
to be more readable.
- strncpy(prog, argv[0], strlen(argv[0]));
+ if (strlen(argv[0]) >= LEN_MAX){
+ fprintf(stderr, "Very big executable name: %s\n", argv[0]);
+ return 1;
+ }
+
+ strncpy(prog, argv[0], sizeof(prog) - 1);
return test_harness(dscr_inherit_exec, "dscr_inherit_exec_test");
^ permalink raw reply
* Re: [PATCH] selftests/powerpc: Fix strncpy usage
From: Christophe LEROY @ 2018-06-22 14:51 UTC (permalink / raw)
To: Breno Leitao, Segher Boessenkool; +Cc: linuxppc-dev, Anshuman Khandual
In-Reply-To: <1dc025d5-366c-ae13-259e-dae543e6ec52@debian.org>
Le 22/06/2018 à 16:43, Breno Leitao a écrit :
> Hi Segher,
>
> On 06/21/2018 08:18 PM, Segher Boessenkool wrote:
>> On Wed, Jun 20, 2018 at 07:51:11PM -0300, Breno Leitao wrote:
>>> - strncpy(prog, argv[0], strlen(argv[0]));
>>> + strncpy(prog, argv[0], sizeof(prog) - 1);
>>
>> strncpy(prog, argv[0], sizeof prog);
>> if (prog[sizeof prog - 1])
>> scream_bloody_murder();
>>
>> Silently using the wrong data is a worse habit than not checking for
>> overflows ;-)
>
> Completely agree! Thanks for bringing this up.
>
> If you don't mind, I would solve this problem slightly different, as it seems
> to be more readable.
>
>
> - strncpy(prog, argv[0], strlen(argv[0]));
> + if (strlen(argv[0]) >= LEN_MAX){
wouldn't it be better to use sizeof(prog) instead of LEN_MAX ?
> + fprintf(stderr, "Very big executable name: %s\n", argv[0]);
> + return 1;
> + }
> +
> + strncpy(prog, argv[0], sizeof(prog) - 1);
You have checked before that argv[0] is not too long, so you should not
need to use strncpy(), strcpy() would do it.
> return test_harness(dscr_inherit_exec, "dscr_inherit_exec_test");
>
Christophe
^ permalink raw reply
* Re: [PATCH] powerpc/mm: fix always true/false warning in slice.c
From: Mathieu Malaterre @ 2018-06-22 14:55 UTC (permalink / raw)
To: Christophe LEROY
Cc: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
Aneesh Kumar K.V, LKML, linuxppc-dev
In-Reply-To: <63b696ab7be8b941fa1e1589f28260320d12a32a.1529589640.git.christophe.leroy@c-s.fr>
On Fri, Jun 22, 2018 at 3:49 PM Christophe Leroy
<christophe.leroy@c-s.fr> wrote:
>
> This patch fixes the following warnings (obtained with make W=1).
>
> arch/powerpc/mm/slice.c: In function 'slice_range_to_mask':
> arch/powerpc/mm/slice.c:73:12: error: comparison is always true due to limited range of data type [-Werror=type-limits]
> if (start < SLICE_LOW_TOP) {
> ^
> arch/powerpc/mm/slice.c:81:20: error: comparison is always false due to limited range of data type [-Werror=type-limits]
> if ((start + len) > SLICE_LOW_TOP) {
> ^
> arch/powerpc/mm/slice.c: In function 'slice_mask_for_free':
> arch/powerpc/mm/slice.c:136:17: error: comparison is always true due to limited range of data type [-Werror=type-limits]
> if (high_limit <= SLICE_LOW_TOP)
> ^
> arch/powerpc/mm/slice.c: In function 'slice_check_range_fits':
> arch/powerpc/mm/slice.c:185:12: error: comparison is always true due to limited range of data type [-Werror=type-limits]
> if (start < SLICE_LOW_TOP) {
> ^
> arch/powerpc/mm/slice.c:195:39: error: comparison is always false due to limited range of data type [-Werror=type-limits]
> if (SLICE_NUM_HIGH && ((start + len) > SLICE_LOW_TOP)) {
> ^
> arch/powerpc/mm/slice.c: In function 'slice_scan_available':
> arch/powerpc/mm/slice.c:306:11: error: comparison is always true due to limited range of data type [-Werror=type-limits]
> if (addr < SLICE_LOW_TOP) {
> ^
> arch/powerpc/mm/slice.c: In function 'get_slice_psize':
> arch/powerpc/mm/slice.c:709:11: error: comparison is always true due to limited range of data type [-Werror=type-limits]
> if (addr < SLICE_LOW_TOP) {
> ^
>
> Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
> ---
> arch/powerpc/mm/slice.c | 21 ++++++++++++++-------
> 1 file changed, 14 insertions(+), 7 deletions(-)
>
> diff --git a/arch/powerpc/mm/slice.c b/arch/powerpc/mm/slice.c
> index 9530c6db406a..17c57760e06c 100644
> --- a/arch/powerpc/mm/slice.c
> +++ b/arch/powerpc/mm/slice.c
> @@ -62,6 +62,13 @@ static void slice_print_mask(const char *label, const struct slice_mask *mask) {
>
> #endif
>
> +static inline bool slice_addr_is_low(unsigned long addr)
> +{
> + u64 tmp = (u64)addr;
> +
> + return tmp < SLICE_LOW_TOP;
> +}
> +
> static void slice_range_to_mask(unsigned long start, unsigned long len,
> struct slice_mask *ret)
> {
> @@ -71,7 +78,7 @@ static void slice_range_to_mask(unsigned long start, unsigned long len,
> if (SLICE_NUM_HIGH)
> bitmap_zero(ret->high_slices, SLICE_NUM_HIGH);
>
> - if (start < SLICE_LOW_TOP) {
> + if (slice_addr_is_low(start)) {
> unsigned long mend = min(end,
> (unsigned long)(SLICE_LOW_TOP - 1));
>
> @@ -79,7 +86,7 @@ static void slice_range_to_mask(unsigned long start, unsigned long len,
> - (1u << GET_LOW_SLICE_INDEX(start));
> }
>
> - if ((start + len) > SLICE_LOW_TOP) {
> + if (!slice_addr_is_low(end)) {
> unsigned long start_index = GET_HIGH_SLICE_INDEX(start);
> unsigned long align_end = ALIGN(end, (1UL << SLICE_HIGH_SHIFT));
> unsigned long count = GET_HIGH_SLICE_INDEX(align_end) - start_index;
> @@ -134,7 +141,7 @@ static void slice_mask_for_free(struct mm_struct *mm, struct slice_mask *ret,
> if (!slice_low_has_vma(mm, i))
> ret->low_slices |= 1u << i;
>
> - if (high_limit <= SLICE_LOW_TOP)
> + if (slice_addr_is_low(high_limit - 1))
Is high_limit ever going to be 0 ?
> return;
>
> for (i = 0; i < GET_HIGH_SLICE_INDEX(high_limit); i++)
> @@ -183,7 +190,7 @@ static bool slice_check_range_fits(struct mm_struct *mm,
> unsigned long end = start + len - 1;
> u64 low_slices = 0;
>
> - if (start < SLICE_LOW_TOP) {
> + if (slice_addr_is_low(start)) {
> unsigned long mend = min(end,
> (unsigned long)(SLICE_LOW_TOP - 1));
>
> @@ -193,7 +200,7 @@ static bool slice_check_range_fits(struct mm_struct *mm,
> if ((low_slices & available->low_slices) != low_slices)
> return false;
>
> - if (SLICE_NUM_HIGH && ((start + len) > SLICE_LOW_TOP)) {
> + if (SLICE_NUM_HIGH && !slice_addr_is_low(end)) {
> unsigned long start_index = GET_HIGH_SLICE_INDEX(start);
> unsigned long align_end = ALIGN(end, (1UL << SLICE_HIGH_SHIFT));
> unsigned long count = GET_HIGH_SLICE_INDEX(align_end) - start_index;
> @@ -304,7 +311,7 @@ static bool slice_scan_available(unsigned long addr,
> int end, unsigned long *boundary_addr)
> {
> unsigned long slice;
> - if (addr < SLICE_LOW_TOP) {
> + if (slice_addr_is_low(addr)) {
> slice = GET_LOW_SLICE_INDEX(addr);
> *boundary_addr = (slice + end) << SLICE_LOW_SHIFT;
> return !!(available->low_slices & (1u << slice));
> @@ -707,7 +714,7 @@ unsigned int get_slice_psize(struct mm_struct *mm, unsigned long addr)
>
> VM_BUG_ON(radix_enabled());
>
> - if (addr < SLICE_LOW_TOP) {
> + if (slice_addr_is_low(addr)) {
> psizes = mm->context.low_slices_psize;
> index = GET_LOW_SLICE_INDEX(addr);
> } else {
> --
> 2.13.3
>
^ permalink raw reply
* Re: [PATCH] selftests/powerpc: Fix strncpy usage
From: Paul Clarke @ 2018-06-22 15:15 UTC (permalink / raw)
To: Breno Leitao, Segher Boessenkool; +Cc: linuxppc-dev, Anshuman Khandual
In-Reply-To: <1dc025d5-366c-ae13-259e-dae543e6ec52@debian.org>
On 06/22/2018 09:43 AM, Breno Leitao wrote:
> If you don't mind, I would solve this problem slightly different, as it seems
> to be more readable.
>
> - strncpy(prog, argv[0], strlen(argv[0]));
> + if (strlen(argv[0]) >= LEN_MAX){
> + fprintf(stderr, "Very big executable name: %s\n", argv[0]);
"Very big" is an observation. "Too big" indicates a problem better. Or, more explicitly "Executable name is too long".
PC
^ permalink raw reply
* Re: [PATCH] powerpc/mm: fix always true/false warning in slice.c
From: Christophe LEROY @ 2018-06-22 16:17 UTC (permalink / raw)
To: Mathieu Malaterre
Cc: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
Aneesh Kumar K.V, LKML, linuxppc-dev
In-Reply-To: <CA+7wUszwUKjdQzdekaE-CJ1_d9JR9HCz5od1L390EMpRbfTfng@mail.gmail.com>
Le 22/06/2018 à 16:55, Mathieu Malaterre a écrit :
> On Fri, Jun 22, 2018 at 3:49 PM Christophe Leroy
> <christophe.leroy@c-s.fr> wrote:
>>
>> This patch fixes the following warnings (obtained with make W=1).
>>
>> arch/powerpc/mm/slice.c: In function 'slice_range_to_mask':
>> arch/powerpc/mm/slice.c:73:12: error: comparison is always true due to limited range of data type [-Werror=type-limits]
>> if (start < SLICE_LOW_TOP) {
>> ^
>> arch/powerpc/mm/slice.c:81:20: error: comparison is always false due to limited range of data type [-Werror=type-limits]
>> if ((start + len) > SLICE_LOW_TOP) {
>> ^
>> arch/powerpc/mm/slice.c: In function 'slice_mask_for_free':
>> arch/powerpc/mm/slice.c:136:17: error: comparison is always true due to limited range of data type [-Werror=type-limits]
>> if (high_limit <= SLICE_LOW_TOP)
>> ^
>> arch/powerpc/mm/slice.c: In function 'slice_check_range_fits':
>> arch/powerpc/mm/slice.c:185:12: error: comparison is always true due to limited range of data type [-Werror=type-limits]
>> if (start < SLICE_LOW_TOP) {
>> ^
>> arch/powerpc/mm/slice.c:195:39: error: comparison is always false due to limited range of data type [-Werror=type-limits]
>> if (SLICE_NUM_HIGH && ((start + len) > SLICE_LOW_TOP)) {
>> ^
>> arch/powerpc/mm/slice.c: In function 'slice_scan_available':
>> arch/powerpc/mm/slice.c:306:11: error: comparison is always true due to limited range of data type [-Werror=type-limits]
>> if (addr < SLICE_LOW_TOP) {
>> ^
>> arch/powerpc/mm/slice.c: In function 'get_slice_psize':
>> arch/powerpc/mm/slice.c:709:11: error: comparison is always true due to limited range of data type [-Werror=type-limits]
>> if (addr < SLICE_LOW_TOP) {
>> ^
>>
>> Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
>> ---
>> arch/powerpc/mm/slice.c | 21 ++++++++++++++-------
>> 1 file changed, 14 insertions(+), 7 deletions(-)
>>
>> diff --git a/arch/powerpc/mm/slice.c b/arch/powerpc/mm/slice.c
>> index 9530c6db406a..17c57760e06c 100644
>> --- a/arch/powerpc/mm/slice.c
>> +++ b/arch/powerpc/mm/slice.c
>> @@ -62,6 +62,13 @@ static void slice_print_mask(const char *label, const struct slice_mask *mask) {
>>
>> #endif
>>
>> +static inline bool slice_addr_is_low(unsigned long addr)
>> +{
>> + u64 tmp = (u64)addr;
>> +
>> + return tmp < SLICE_LOW_TOP;
>> +}
>> +
>> static void slice_range_to_mask(unsigned long start, unsigned long len,
>> struct slice_mask *ret)
>> {
>> @@ -71,7 +78,7 @@ static void slice_range_to_mask(unsigned long start, unsigned long len,
>> if (SLICE_NUM_HIGH)
>> bitmap_zero(ret->high_slices, SLICE_NUM_HIGH);
>>
>> - if (start < SLICE_LOW_TOP) {
>> + if (slice_addr_is_low(start)) {
>> unsigned long mend = min(end,
>> (unsigned long)(SLICE_LOW_TOP - 1));
>>
>> @@ -79,7 +86,7 @@ static void slice_range_to_mask(unsigned long start, unsigned long len,
>> - (1u << GET_LOW_SLICE_INDEX(start));
>> }
>>
>> - if ((start + len) > SLICE_LOW_TOP) {
>> + if (!slice_addr_is_low(end)) {
>> unsigned long start_index = GET_HIGH_SLICE_INDEX(start);
>> unsigned long align_end = ALIGN(end, (1UL << SLICE_HIGH_SHIFT));
>> unsigned long count = GET_HIGH_SLICE_INDEX(align_end) - start_index;
>> @@ -134,7 +141,7 @@ static void slice_mask_for_free(struct mm_struct *mm, struct slice_mask *ret,
>> if (!slice_low_has_vma(mm, i))
>> ret->low_slices |= 1u << i;
>>
>> - if (high_limit <= SLICE_LOW_TOP)
>> + if (slice_addr_is_low(high_limit - 1))
>
> Is high_limit ever going to be 0 ?
See slice_get_unmapped_area(), high_limit will never be 0.
Christophe
>
>> return;
>>
>> for (i = 0; i < GET_HIGH_SLICE_INDEX(high_limit); i++)
>> @@ -183,7 +190,7 @@ static bool slice_check_range_fits(struct mm_struct *mm,
>> unsigned long end = start + len - 1;
>> u64 low_slices = 0;
>>
>> - if (start < SLICE_LOW_TOP) {
>> + if (slice_addr_is_low(start)) {
>> unsigned long mend = min(end,
>> (unsigned long)(SLICE_LOW_TOP - 1));
>>
>> @@ -193,7 +200,7 @@ static bool slice_check_range_fits(struct mm_struct *mm,
>> if ((low_slices & available->low_slices) != low_slices)
>> return false;
>>
>> - if (SLICE_NUM_HIGH && ((start + len) > SLICE_LOW_TOP)) {
>> + if (SLICE_NUM_HIGH && !slice_addr_is_low(end)) {
>> unsigned long start_index = GET_HIGH_SLICE_INDEX(start);
>> unsigned long align_end = ALIGN(end, (1UL << SLICE_HIGH_SHIFT));
>> unsigned long count = GET_HIGH_SLICE_INDEX(align_end) - start_index;
>> @@ -304,7 +311,7 @@ static bool slice_scan_available(unsigned long addr,
>> int end, unsigned long *boundary_addr)
>> {
>> unsigned long slice;
>> - if (addr < SLICE_LOW_TOP) {
>> + if (slice_addr_is_low(addr)) {
>> slice = GET_LOW_SLICE_INDEX(addr);
>> *boundary_addr = (slice + end) << SLICE_LOW_SHIFT;
>> return !!(available->low_slices & (1u << slice));
>> @@ -707,7 +714,7 @@ unsigned int get_slice_psize(struct mm_struct *mm, unsigned long addr)
>>
>> VM_BUG_ON(radix_enabled());
>>
>> - if (addr < SLICE_LOW_TOP) {
>> + if (slice_addr_is_low(addr)) {
>> psizes = mm->context.low_slices_psize;
>> index = GET_LOW_SLICE_INDEX(addr);
>> } else {
>> --
>> 2.13.3
>>
^ permalink raw reply
* Re: [PATCH 1/2] powerpc: Document issues with the DAWR on POWER9
From: Segher Boessenkool @ 2018-06-22 17:23 UTC (permalink / raw)
To: Michael Neuling; +Cc: mpe, linuxppc-dev
In-Reply-To: <20180622061452.19016-1-mikey@neuling.org>
On Fri, Jun 22, 2018 at 04:14:51PM +1000, Michael Neuling wrote:
> +will accept the command. Unfortunatley since there is no hardware
"unfortunately".
> +speed since it can use the hardware emualation. Unfortnatley if this
It is not your favourite word to type ;-)
Segher
^ permalink raw reply
* Re: [PATCH 2/2] powerpc: Document issues with TM on POWER9
From: Segher Boessenkool @ 2018-06-22 17:27 UTC (permalink / raw)
To: Michael Neuling; +Cc: mpe, linuxppc-dev
In-Reply-To: <20180622061452.19016-2-mikey@neuling.org>
On Fri, Jun 22, 2018 at 04:14:52PM +1000, Michael Neuling wrote:
> +degredation. Host userspace has TM disabled
"degradation"
> +POWER9C DD1.2 and above are only avaliable with POWERNV and hence
"available"
Segher
^ permalink raw reply
* [PATCH] powerpc: include setup.h header file to fix warnings
From: Mathieu Malaterre @ 2018-06-22 19:26 UTC (permalink / raw)
To: Michael Ellerman
Cc: Mathieu Malaterre, Benjamin Herrenschmidt, Paul Mackerras,
Christophe Leroy, linuxppc-dev, linux-kernel
Make sure to include setup.h to provide the following prototypes:
- irqstack_early_init
- setup_power_save
- initialize_cache_info
Fix the following warnings (treated as error in W=1):
arch/powerpc/kernel/setup_32.c:198:13: error: no previous prototype for ‘irqstack_early_init’ [-Werror=missing-prototypes]
arch/powerpc/kernel/setup_32.c:238:13: error: no previous prototype for ‘setup_power_save’ [-Werror=missing-prototypes]
arch/powerpc/kernel/setup_32.c:253:13: error: no previous prototype for ‘initialize_cache_info’ [-Werror=missing-prototypes]
Signed-off-by: Mathieu Malaterre <malat@debian.org>
---
arch/powerpc/kernel/setup_32.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/arch/powerpc/kernel/setup_32.c b/arch/powerpc/kernel/setup_32.c
index 74457485574b..9827b6b3aaaa 100644
--- a/arch/powerpc/kernel/setup_32.c
+++ b/arch/powerpc/kernel/setup_32.c
@@ -41,6 +41,8 @@
#include <asm/cpu_has_feature.h>
#include <asm/asm-prototypes.h>
+#include "setup.h"
+
#define DBG(fmt...)
extern void bootx_init(unsigned long r4, unsigned long phys);
--
2.11.0
^ permalink raw reply related
* [PATCH] powerpc/xmon: avoid warnings about variables that might be clobbered by ‘longjmp’
From: Mathieu Malaterre @ 2018-06-22 19:27 UTC (permalink / raw)
To: Michael Ellerman
Cc: Mathieu Malaterre, Benjamin Herrenschmidt, Paul Mackerras,
Balbir Singh, Nicholas Piggin, Vaibhav Jain, Breno Leitao,
Yisheng Xie, linuxppc-dev, linux-kernel
Move initialization of variables after data definitions. This silence
warnings treated as error with W=1:
arch/powerpc/xmon/xmon.c:3389:14: error: variable ‘name’ might be clobbered by ‘longjmp’ or ‘vfork’ [-Werror=clobbered]
arch/powerpc/xmon/xmon.c:3100:22: error: variable ‘tsk’ might be clobbered by ‘longjmp’ or ‘vfork’ [-Werror=clobbered]
Signed-off-by: Mathieu Malaterre <malat@debian.org>
---
arch/powerpc/xmon/xmon.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c
index 47166ad2a669..982848c784ff 100644
--- a/arch/powerpc/xmon/xmon.c
+++ b/arch/powerpc/xmon/xmon.c
@@ -3097,10 +3097,11 @@ static void show_pte(unsigned long addr)
static void show_tasks(void)
{
unsigned long tskv;
- struct task_struct *tsk = NULL;
+ struct task_struct *tsk;
printf(" task_struct ->thread.ksp PID PPID S P CMD\n");
+ tsk = NULL;
if (scanhex(&tskv))
tsk = (struct task_struct *)tskv;
@@ -3386,10 +3387,11 @@ static void xmon_print_symbol(unsigned long address, const char *mid,
const char *after)
{
char *modname;
- const char *name = NULL;
+ const char *name;
unsigned long offset, size;
printf(REG, address);
+ name = NULL;
if (setjmp(bus_error_jmp) == 0) {
catch_memory_errors = 1;
sync();
--
2.11.0
^ permalink raw reply related
* [PATCH] powerpc/mm: remove warning about ‘type’ being set
From: Mathieu Malaterre @ 2018-06-22 19:27 UTC (permalink / raw)
To: Michael Ellerman
Cc: Mathieu Malaterre, Benjamin Herrenschmidt, Paul Mackerras,
Thomas Gleixner, Greg Kroah-Hartman, Philippe Ombredanne,
Kate Stewart, linuxppc-dev, linux-kernel
‘type’ is only used when CONFIG_DEBUG_HIGHMEM is set. So add a possibly
unused tag to variable. Remove warning treated as error with W=1:
arch/powerpc/mm/highmem.c:59:6: error: variable ‘type’ set but not used [-Werror=unused-but-set-variable]
Signed-off-by: Mathieu Malaterre <malat@debian.org>
---
arch/powerpc/mm/highmem.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/powerpc/mm/highmem.c b/arch/powerpc/mm/highmem.c
index 668e87d03f9e..82a0e37557a5 100644
--- a/arch/powerpc/mm/highmem.c
+++ b/arch/powerpc/mm/highmem.c
@@ -56,7 +56,7 @@ EXPORT_SYMBOL(kmap_atomic_prot);
void __kunmap_atomic(void *kvaddr)
{
unsigned long vaddr = (unsigned long) kvaddr & PAGE_MASK;
- int type;
+ int type __maybe_unused;
if (vaddr < __fix_to_virt(FIX_KMAP_END)) {
pagefault_enable();
--
2.11.0
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox