Re: [PATCH v7] staging: typec: handle vendor defined part and modify drp toggling flow
Hi Jun, 2018-03-12 13:58 GMT+08:00 Jun Li : > Hi >> -Original Message- >> From: 李書帆 [mailto:leechu...@gmail.com] >> Sent: 2018年3月12日 13:22 >> To: Jun Li >> Cc: Greg Kroah-Hartman ; >> heikki.kroge...@linux.intel.com; li...@roeck-us.net; g...@kroah.com; >> shufan_...@richtek.com; cy_hu...@richtek.com; >> linux-kernel@vger.kernel.org; linux-...@vger.kernel.org >> Subject: Re: [PATCH v7] staging: typec: handle vendor defined part and modify >> drp toggling flow >> >> Hi Jun, >> >> Thank you. >> >> 2018-03-12 12:33 GMT+08:00 Jun Li : >> > Hi, >> > >> >> +static irqreturn_t _tcpci_irq(int irq, void *dev_id) { >> >> + struct tcpci *tcpci = dev_id; >> >> + >> >> + return tcpci_irq(tcpci); >> >> +} >> >> >> > ... >> > >> >> + err = devm_request_threaded_irq(&client->dev, client->irq, NULL, >> >> + _tcpci_irq, >> >> IRQF_ONESHOT | >> IRQF_TRIGGER_LOW, >> >> - dev_name(tcpci->dev), tcpci); >> >> + dev_name(&client->dev), chip); >> > >> > - dev_name(&client->dev), chip); >> > + dev_name(&client->dev), chip->tcpci); >> > >> > Did you ever test this patch? >> I've tested this patch with tcpci_rt1711h.c that will be sent out for >> reviewing in >> the next patch after tcpci's modification is passed. >> Because interrupt handler is registered in tcpci_rt1711h.c, here is the >> place I >> didn't notice. > > Understood. > >> The interrupt handler for tcpci.c should be modified as following: >> static irqreturn_t _tcpci_irq(int irq, void *dev_id) { >> - struct tcpci *tcpci = dev_id; >> + struct tcpci_chip *chip = dev_id; >> >> - return tcpci_irq(tcpci); >> + return tcpci_irq(chip->tcpci); >> } >> > > Either way is OK to fix it. > You may send out your v8 and notify Greg to drop your v7 version. > > Jun Li May I add you in the Reported-by list? -- Best Regards, 書帆
Re: [PATCH][rds-next] rds: make functions rds_info_from_znotifier and rds_message_zcopy_from_user static
On 3/11/18 10:03 AM, Colin King wrote: From: Colin Ian King Functions rds_info_from_znotifier and rds_message_zcopy_from_user are local to the source and do not need to be in global scope, so make them static. Cleans up sparse warnins: net/rds/message.c:70:27: warning: symbol 'rds_info_from_znotifier' was not declared. Should it be static? net/rds/message.c:358:5: warning: symbol 'rds_message_zcopy_from_user' was not declared. Should it be static? Signed-off-by: Colin Ian King --- net/rds/message.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) Acked-by: Santosh Shilimkar
Re: [PATCH][rds-next] rds: remove redundant variable 'sg_off'
On 3/11/18 9:27 AM, Colin King wrote: From: Colin Ian King Variable sg_off is assigned a value but it is never read, hence it is redundant and can be removed. Cleans up clang warning: net/rds/message.c:373:2: warning: Value stored to 'sg_off' is never read Signed-off-by: Colin Ian King --- net/rds/message.c | 2 -- 1 file changed, 2 deletions(-) Thanks Colin !! Acked-by: Santosh Shilimkar
Re: [PATCH v4.16-rc4 1/2] x86/vdso: on Intel, VDSO should handle CLOCK_MONOTONIC_RAW
On Mon, 12 Mar 2018, Jason Vas Dias wrote: checkpatch.pl still reports: total: 15 errors, 3 warnings, 165 lines checked > +notrace static u64 vread_tsc_raw(void) > +{ > + u64 tsc, last=gtod->raw_cycle_last; > + if( likely( gtod->has_rdtscp ) ) > + tsc = rdtscp((void*)0); Plus I asked more than once to split that rdtscp() stuff into a separate patch. You surely are free to ignore my review comments, but rest assured that I'm free to ignore the crap you insist to send me as well. Thanks, tglx
[RFC PATCH 1/4] irqchip/gic-v3: add common_aff_lpi field in struct rdists
Read CommonLPIAff from GICR_TYPER and check whether the values are same in each register. If they are different, prints warning message and set CommonLPIAff to zero. Signed-off-by: Yang Yingliang --- drivers/irqchip/irq-gic-v3.c | 20 include/linux/irqchip/arm-gic-v3.h | 3 +++ 2 files changed, 23 insertions(+) diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c index d99cc07..58f55da 100644 --- a/drivers/irqchip/irq-gic-v3.c +++ b/drivers/irqchip/irq-gic-v3.c @@ -598,6 +598,10 @@ static int gic_dist_supports_lpis(void) static void gic_cpu_init(void) { void __iomem *rbase; + u32 typer; + unsigned long flags; + u16 common_aff_lpi; + int cpu = smp_processor_id(); /* Register ourselves with the rest of the world */ if (gic_populate_rdist()) @@ -612,6 +616,21 @@ static void gic_cpu_init(void) gic_cpu_config(rbase, gic_redist_wait_for_rwp); + typer = gic_read_typer(gic_data_rdist_rd_base() + GICR_TYPER); + common_aff_lpi = GICR_TYPER_COMMON_AFF_LPI(typer); + if (!cpu) { + gic_data.rdists.common_aff_lpi = common_aff_lpi; + } else { + raw_spin_lock_irqsave(&gic_data.rdists.lock, flags); + if (common_aff_lpi != gic_data.rdists.common_aff_lpi) { + pr_warn_once("The CommonLPIAff is not consistent.\ +It's %d in CPU0, but %d in CPU%d, set CommonLPIAff to 0.\n", + gic_data.rdists.common_aff_lpi, cpu, common_aff_lpi); + gic_data.rdists.common_aff_lpi = 0; + } + raw_spin_unlock_irqrestore(&gic_data.rdists.lock, flags); + } + /* Give LPIs a spin */ if (IS_ENABLED(CONFIG_ARM_GIC_V3_ITS) && gic_dist_supports_lpis()) its_cpu_init(); @@ -1029,6 +1048,7 @@ static int __init gic_init_bases(void __iomem *dist_base, gic_data.rdists.rdist = alloc_percpu(typeof(*gic_data.rdists.rdist)); gic_data.rdists.has_vlpis = true; gic_data.rdists.has_direct_lpi = true; + raw_spin_lock_init(&gic_data.rdists.lock); if (WARN_ON(!gic_data.domain) || WARN_ON(!gic_data.rdists.rdist)) { err = -ENOMEM; diff --git a/include/linux/irqchip/arm-gic-v3.h b/include/linux/irqchip/arm-gic-v3.h index c00c4c33..6da670a 100644 --- a/include/linux/irqchip/arm-gic-v3.h +++ b/include/linux/irqchip/arm-gic-v3.h @@ -108,6 +108,7 @@ #define GICR_CTLR_ENABLE_LPIS (1UL << 0) #define GICR_TYPER_CPU_NUMBER(r) (((r) >> 8) & 0x) +#define GICR_TYPER_COMMON_AFF_LPI(r) (((r) >> 24) & 3) #define GICR_WAKER_ProcessorSleep (1U << 1) #define GICR_WAKER_ChildrenAsleep (1U << 2) @@ -577,6 +578,8 @@ struct rdists { u64 flags; boolhas_vlpis; boolhas_direct_lpi; + u16 common_aff_lpi; + raw_spinlock_t lock; }; struct irq_domain; -- 1.8.3
[RFC PATCH 4/4] irqchip/gic-v3-its: sync config of LPIs if there are more than one prop_page
The config of LPIs need to be same in each prop_page. So if one prop_page is modified, other prop_page should be updated too. Signed-off-by: Yang Yingliang --- drivers/irqchip/irq-gic-v3-its.c | 39 ++- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c index 02a5d95..27306a5 100644 --- a/drivers/irqchip/irq-gic-v3-its.c +++ b/drivers/irqchip/irq-gic-v3-its.c @@ -1051,11 +1051,25 @@ static inline u32 its_get_event_id(struct irq_data *d) return d->hwirq - its_dev->event_map.lpi_base; } +static inline void lpi_flush_config(u8 *cfg) +{ + /* +* Make the above write visible to the redistributors. +* And yes, we're flushing exactly: One. Single. Byte. +* Humpf... +*/ + if (gic_rdists->flags & RDIST_FLAGS_PROPBASE_NEEDS_FLUSHING) + gic_flush_dcache_to_poc(cfg, sizeof(*cfg)); + else + dsb(ishst); +} + static void lpi_write_config(struct irq_data *d, u8 clr, u8 set) { irq_hw_number_t hwirq; struct page *prop_page; u8 *cfg; + int cpu; if (irqd_is_forwarded_to_vcpu(d)) { struct its_device *its_dev = irq_data_get_irq_chip_data(d); @@ -1078,15 +1092,22 @@ static void lpi_write_config(struct irq_data *d, u8 clr, u8 set) *cfg &= ~clr; *cfg |= set | LPI_PROP_GROUP1; - /* -* Make the above write visible to the redistributors. -* And yes, we're flushing exactly: One. Single. Byte. -* Humpf... -*/ - if (gic_rdists->flags & RDIST_FLAGS_PROPBASE_NEEDS_FLUSHING) - gic_flush_dcache_to_poc(cfg, sizeof(*cfg)); - else - dsb(ishst); + if (gic_rdists->common_aff_lpi) { + /* It's protected by desc->lock, don't need lock any more. */ + for_each_cpu(cpu, cpu_possible_mask) { + u8 *other_cfg; + struct page *other_prop_page = per_cpu_ptr(gic_rdists->rdist, cpu)->prop_page; + + if (other_prop_page == prop_page) + continue; + + other_cfg = page_address(other_prop_page) + hwirq - 8192; + *other_cfg = *cfg; + lpi_flush_config(other_cfg); + } + } else { + lpi_flush_config(cfg); + } } static void lpi_update_config(struct irq_data *d, u8 clr, u8 set) -- 1.8.3
[RFC PATCH 3/4] irqchip/gic-v3-its: change prop_page to per-cpu type to support CommonLPIAff field
Change prop_page to per-cpu type and add its_cpu_allocate_prop_tables() to allocate LPI property tables. This function is called by each oneline cpu and allocate tables according to the value of CommonLPIAff. The spec defines the field: CommonLPIAff, bits [25:24] The affinity level at which Redistributors share a LPI Configuration table. 00 All Redistributors must share a LPI Configuration table. 01 All Redistributors with the same Aff3 value must share an LPI Configurationt table. 10 All Redistributors with the same Aff3.Aff2 value must share an LPI Configuration table. 11 All Redistributors with the same Aff3.Aff2.Aff1 value must share an LPI Configuration table. Signed-off-by: Yang Yingliang --- drivers/irqchip/irq-gic-v3-its.c | 81 -- include/linux/irqchip/arm-gic-v3.h | 6 ++- 2 files changed, 65 insertions(+), 22 deletions(-) diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c index 4ebe131..02a5d95 100644 --- a/drivers/irqchip/irq-gic-v3-its.c +++ b/drivers/irqchip/irq-gic-v3-its.c @@ -1070,7 +1070,7 @@ static void lpi_write_config(struct irq_data *d, u8 clr, u8 set) map->properties &= ~clr; map->properties |= set | LPI_PROP_GROUP1; } else { - prop_page = gic_rdists->prop_page; + prop_page = gic_data_rdist()->prop_page; hwirq = d->hwirq; } @@ -1582,24 +1582,6 @@ static void its_free_prop_table(struct page *prop_page) get_order(LPI_PROPBASE_SZ)); } -static int __init its_alloc_lpi_tables(void) -{ - phys_addr_t paddr; - - lpi_id_bits = min_t(u32, gic_rdists->id_bits, ITS_MAX_LPI_NRBITS); - gic_rdists->prop_page = its_allocate_prop_table(cpu_to_node(smp_processor_id()), - GFP_NOWAIT); - if (!gic_rdists->prop_page) { - pr_err("Failed to allocate PROPBASE\n"); - return -ENOMEM; - } - - paddr = page_to_phys(gic_rdists->prop_page); - pr_info("GIC: using LPI property table @%pa\n", &paddr); - - return its_lpi_init(lpi_id_bits); -} - static const char *its_base_type_string[] = { [GITS_BASER_TYPE_DEVICE]= "Devices", [GITS_BASER_TYPE_VCPU] = "Virtual CPUs", @@ -1935,7 +1917,7 @@ static void its_cpu_init_lpis(void) dsb(sy); /* set PROPBASE */ - val = (page_to_phys(gic_rdists->prop_page) | + val = (page_to_phys(gic_data_rdist()->prop_page) | GICR_PROPBASER_InnerShareable | GICR_PROPBASER_RaWaWb | ((LPI_NRBITS - 1) & GICR_PROPBASER_IDBITS_MASK)); @@ -2037,6 +2019,59 @@ static void its_cpu_init_collection(void) spin_unlock(&its_lock); } +static int __init its_cpu_allocate_prop_tables(void) +{ + phys_addr_t paddr; + unsigned long flags; + int match_cpu; + u64 aff_mask = 0; + struct page *prop_page = NULL; + int cpu = smp_processor_id(); + + switch (gic_rdists->common_aff_lpi) { + case GICR_COMMON_ALL_SHARE: + aff_mask = 0; + break; + case GICR_COMMON_AFF3_SHARE: + aff_mask = 0xffULL << MPIDR_LEVEL_SHIFT(3); + break; + case GICR_COMMON_AFF3_AFF2_SHARE: + aff_mask = (0xffULL << MPIDR_LEVEL_SHIFT(3)) | + (0xffULL << MPIDR_LEVEL_SHIFT(2)); + break; + case GICR_COMMON_AFF3_AFF2_AFF1_SHARE: + aff_mask = (0xffULL << MPIDR_LEVEL_SHIFT(3)) | + (0xffULL << MPIDR_LEVEL_SHIFT(2)) | + (0xffULL << MPIDR_LEVEL_SHIFT(1)); + break; + default: + pr_err("Bad common_aff_lpi:%d\n", gic_rdists->common_aff_lpi); + } + + raw_spin_lock_irqsave(&gic_rdists->lock, flags); + for_each_cpu(match_cpu, cpu_possible_mask) { + struct page *match_prop_page = per_cpu_ptr(gic_rdists->rdist, match_cpu)->prop_page; + if ((cpu_logical_map(cpu) & aff_mask) == (cpu_logical_map(match_cpu) & aff_mask) && + match_prop_page) { + prop_page = match_prop_page; + break; + } + } + if (!prop_page) { + prop_page = its_allocate_prop_table(cpu_to_node(cpu), GFP_NOWAIT); + pr_err("Failed to allocate PROPBASE\n"); + raw_spin_unlock_irqrestore(&gic_rdists->lock, flags); + return -ENOMEM; + } + gic_data_rdist()->prop_page = prop_page; + raw_spin_unlock_irqrestore(&gic_rdists->lock, flags); + + paddr = page_to_phys(gic_data_rdist()->prop_page); + pr_info("CPU%d using LPI property table @%pa\n", cpu, &paddr); + + return 0; +} + static struct its_device *its_find_device(struct its_node *its, u32 dev_id) { struct it
[RFC PATCH 2/4] irqchip/gic-v3-its: replace alloc_pages() with alloc_pages_node()
Use alloc_pages_node() to allocate pages on current node. Signed-off-by: Yang Yingliang --- drivers/irqchip/irq-gic-v3-its.c | 9 + 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c index a03e18e..4ebe131 100644 --- a/drivers/irqchip/irq-gic-v3-its.c +++ b/drivers/irqchip/irq-gic-v3-its.c @@ -1557,11 +1557,11 @@ static void its_lpi_free_chunks(unsigned long *bitmap, int base, int nr_ids) kfree(bitmap); } -static struct page *its_allocate_prop_table(gfp_t gfp_flags) +static struct page *its_allocate_prop_table(int nid, gfp_t gfp_flags) { struct page *prop_page; - prop_page = alloc_pages(gfp_flags, get_order(LPI_PROPBASE_SZ)); + prop_page = alloc_pages_node(nid, gfp_flags, get_order(LPI_PROPBASE_SZ)); if (!prop_page) return NULL; @@ -1587,7 +1587,8 @@ static int __init its_alloc_lpi_tables(void) phys_addr_t paddr; lpi_id_bits = min_t(u32, gic_rdists->id_bits, ITS_MAX_LPI_NRBITS); - gic_rdists->prop_page = its_allocate_prop_table(GFP_NOWAIT); + gic_rdists->prop_page = its_allocate_prop_table(cpu_to_node(smp_processor_id()), + GFP_NOWAIT); if (!gic_rdists->prop_page) { pr_err("Failed to allocate PROPBASE\n"); return -ENOMEM; @@ -2829,7 +2830,7 @@ static int its_vpe_irq_domain_alloc(struct irq_domain *domain, unsigned int virq return -ENOMEM; } - vprop_page = its_allocate_prop_table(GFP_KERNEL); + vprop_page = its_allocate_prop_table(NUMA_NO_NODE, GFP_KERNEL); if (!vprop_page) { its_lpi_free_chunks(bitmap, base, nr_ids); return -ENOMEM; -- 1.8.3
[RFC PATCH 0/4] add support for CommonLPIAff field
This patch set adjust struct rdists to support CommonLPIAff field. This field is described in spec: CommonLPIAff, bits [25:24] The affinity level at which Redistributors share a LPI Configuration table. 00 All Redistributors must share a LPI Configuration table. 01 All Redistributors with the same Aff3 value must share an LPI Configurationt table. 10 All Redistributors 11 All Redistributors with the same Aff3.Aff2.Aff1 value must share an LPI Configuration table. Yang Yingliang (4): irqchip/gic-v3: add common_aff_lpi field in struct rdists irqchip/gic-v3-its: replace alloc_pages() with alloc_pages_node() irqchip/gic-v3-its: change prop_page to per-cpu type to support CommonLPIAff field irqchip/gic-v3-its: sync config of LPIs if there are more than one prop_page drivers/irqchip/irq-gic-v3-its.c | 125 +++-- drivers/irqchip/irq-gic-v3.c | 20 ++ include/linux/irqchip/arm-gic-v3.h | 9 ++- 3 files changed, 121 insertions(+), 33 deletions(-) -- 1.8.3
Re: [PATCH v4.16-rc4 1/1] x86/vdso: on Intel, VDSO should handle CLOCK_MONOTONIC_RAW
Hi Jason, Thank you for the patch! Yet something to improve: [auto build test ERROR on v4.16-rc4] url: https://github.com/0day-ci/linux/commits/Jason-Vas-Dias/x86-vdso-on-Intel-VDSO-should-handle-CLOCK_MONOTONIC_RAW/20180312-141707 config: x86_64-randconfig-x002-201810 (attached as .config) compiler: gcc-7 (Debian 7.3.0-1) 7.3.0 reproduce: # save the attached .config to linux build tree make ARCH=x86_64 All errors (new ones prefixed by >>): arch/x86/entry/vdso/vclock_gettime.o: In function `__vdso_clock_gettime': >> arch/x86/entry/vdso/vclock_gettime.c:336: undefined reference to >> `__x86_indirect_thunk_rax' /usr/bin/ld: arch/x86/entry/vdso/vclock_gettime.o: relocation R_X86_64_PC32 against undefined symbol `__x86_indirect_thunk_rax' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: final link failed: Bad value collect2: error: ld returned 1 exit status vim +336 arch/x86/entry/vdso/vclock_gettime.c da15cfda arch/x86/vdso/vclock_gettime.c John Stultz 2009-08-19 333 23adec55 arch/x86/vdso/vclock_gettime.c Steven Rostedt 2008-05-12 334 notrace int __vdso_clock_gettime(clockid_t clock, struct timespec *ts) 2aae950b arch/x86_64/vdso/vclock_gettime.cAndi Kleen 2007-07-21 335 { 2aae950b arch/x86_64/vdso/vclock_gettime.cAndi Kleen 2007-07-21 @336 switch (clock) { 2aae950b arch/x86_64/vdso/vclock_gettime.cAndi Kleen 2007-07-21 337 case CLOCK_REALTIME: ce39c640 arch/x86/vdso/vclock_gettime.c Stefani Seibold 2014-03-17 338 if (do_realtime(ts) == VCLOCK_NONE) ce39c640 arch/x86/vdso/vclock_gettime.c Stefani Seibold 2014-03-17 339 goto fallback; da15cfda arch/x86/vdso/vclock_gettime.c John Stultz 2009-08-19 340 break; 2aae950b arch/x86_64/vdso/vclock_gettime.cAndi Kleen 2007-07-21 341 case CLOCK_MONOTONIC: ce39c640 arch/x86/vdso/vclock_gettime.c Stefani Seibold 2014-03-17 342 if (do_monotonic(ts) == VCLOCK_NONE) ce39c640 arch/x86/vdso/vclock_gettime.c Stefani Seibold 2014-03-17 343 goto fallback; da15cfda arch/x86/vdso/vclock_gettime.c John Stultz 2009-08-19 344 break; ff72916d arch/x86/entry/vdso/vclock_gettime.c Jason Vas Dias 2018-03-11 345 case CLOCK_MONOTONIC_RAW: ff72916d arch/x86/entry/vdso/vclock_gettime.c Jason Vas Dias 2018-03-11 346 if (do_monotonic_raw(ts) == VCLOCK_NONE) ff72916d arch/x86/entry/vdso/vclock_gettime.c Jason Vas Dias 2018-03-11 347 goto fallback; ff72916d arch/x86/entry/vdso/vclock_gettime.c Jason Vas Dias 2018-03-11 348 break; da15cfda arch/x86/vdso/vclock_gettime.c John Stultz 2009-08-19 349 case CLOCK_REALTIME_COARSE: ce39c640 arch/x86/vdso/vclock_gettime.c Stefani Seibold 2014-03-17 350 do_realtime_coarse(ts); ce39c640 arch/x86/vdso/vclock_gettime.c Stefani Seibold 2014-03-17 351 break; da15cfda arch/x86/vdso/vclock_gettime.c John Stultz 2009-08-19 352 case CLOCK_MONOTONIC_COARSE: ce39c640 arch/x86/vdso/vclock_gettime.c Stefani Seibold 2014-03-17 353 do_monotonic_coarse(ts); ce39c640 arch/x86/vdso/vclock_gettime.c Stefani Seibold 2014-03-17 354 break; ce39c640 arch/x86/vdso/vclock_gettime.c Stefani Seibold 2014-03-17 355 default: ce39c640 arch/x86/vdso/vclock_gettime.c Stefani Seibold 2014-03-17 356 goto fallback; 2aae950b arch/x86_64/vdso/vclock_gettime.cAndi Kleen 2007-07-21 357 } 0d7b8547 arch/x86/vdso/vclock_gettime.c Andy Lutomirski 2011-06-05 358 a939e817 arch/x86/vdso/vclock_gettime.c John Stultz 2012-03-01 359 return 0; ce39c640 arch/x86/vdso/vclock_gettime.c Stefani Seibold 2014-03-17 360 fallback: ce39c640 arch/x86/vdso/vclock_gettime.c Stefani Seibold 2014-03-17 361 return vdso_fallback_gettime(clock, ts); 2aae950b arch/x86_64/vdso/vclock_gettime.cAndi Kleen 2007-07-21 362 } 2aae950b arch/x86_64/vdso/vclock_gettime.cAndi Kleen 2007-07-21 363 int clock_gettime(clockid_t, struct timespec *) 2aae950b arch/x86_64/vdso/vclock_gettime.cAndi Kleen 2007-07-21 364 __attribute__((weak, alias("__vdso_clock_gettime"))); 2aae950b arch/x86_64/vdso/vclock_gettime.cAndi Kleen 2007-07-21 365 :: The code at line 336 was first introduced by commit :: 2aae950b21e4bc789d1fc6668faf67e8748300b7 x86_64: Add vDSO for x86-64 with gettimeofday/clock_gettime/getcpu :: TO: Andi Kleen :: CC: Linus Torvalds --- 0-DAY kernel test infrastructureOpen Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation .config.gz Description: application/gzip
[PATCH ghak21 V2 1/4] audit: make ANOM_LINK obey audit_enabled and audit_dummy_context
Audit link denied events emit disjointed records when audit is disabled. No records should be emitted when audit is disabled. See: https://github.com/linux-audit/audit-kernel/issues/21 Signed-off-by: Richard Guy Briggs --- kernel/audit.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kernel/audit.c b/kernel/audit.c index 1a3e75d..7026d69 100644 --- a/kernel/audit.c +++ b/kernel/audit.c @@ -2308,6 +2308,9 @@ void audit_log_link_denied(const char *operation, const struct path *link) struct audit_buffer *ab; struct audit_names *name; + if (!audit_enabled || audit_dummy_context()) + return; + name = kzalloc(sizeof(*name), GFP_NOFS); if (!name) return; -- 1.8.3.1
[PATCH ghak21 V2 0/4] audit: address ANOM_LINK excess records
Audit link denied events were being unexpectedly produced in a disjoint way when audit was disabled, and when they were expected, there were duplicate PATH records. This patchset addresses both issues for symlinks and hardlinks. This was introduced with commit b24a30a7305418ff138ff51776fc555ec57c011a ("audit: fix event coverage of AUDIT_ANOM_LINK") commit a51d9eaa41866ab6b4b6ecad7b621f8b66ece0dc ("fs: add link restriction audit reporting") Here are the resulting events: symlink: type=PROCTITLE msg=audit(03/12/2018 02:21:49.578:310) : proctitle=ls ./my-passwd type=PATH msg=audit(03/12/2018 02:21:49.578:310) : item=1 name=/tmp/ inode=13529 dev=00:27 mode=dir,sticky,777 ouid=root ogid=root rdev=00:00 obj=system_u:object_r:tmp_t:s0 nametype=PARENT cap_fp=none cap_fi=none cap_fe=0 cap_fver=0 type=PATH msg=audit(03/12/2018 02:21:49.578:310) : item=0 name=./my-passwd inode=17090 dev=00:27 mode=link,777 ouid=rgb ogid=rgb rdev=00:00 obj=unconfined_u:object_r:user_tmp_t:s0 nametype=NORMAL cap_fp=none cap_fi=none cap_fe=0 cap_fver=0 type=CWD msg=audit(03/12/2018 02:21:49.578:310) : cwd=/tmp type=SYSCALL msg=audit(03/12/2018 02:21:49.578:310) : arch=x86_64 syscall=stat success=no exit=EACCES(Permission denied) a0=0x7ffd79950dda a1=0x563f658a03c8 a2=0x563f658a03c8 a3=0x79950d00 items=2 ppid=552 pid=629 auid=root uid=root gid=root euid=root suid=root fsuid=root egid=root sgid=root fsgid=root tty=ttyS0 ses=1 comm=ls exe=/usr/bin/ls subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 key=(null) type=ANOM_LINK msg=audit(03/12/2018 02:21:49.578:310) : op=follow_link ppid=552 pid=629 auid=root uid=root gid=root euid=root suid=root fsuid=root egid=root sgid=root fsgid=root tty=ttyS0 ses=1 comm=ls exe=/usr/bin/ls subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 res=no hardlink: type=PROCTITLE msg=audit(03/12/2018 02:24:39.813:314) : proctitle=ln test test-ln type=PATH msg=audit(03/12/2018 02:24:39.813:314) : item=1 name=/tmp inode=13529 dev=00:27 mode=dir,sticky,777 ouid=root ogid=root rdev=00:00 obj=system_u:object_r:tmp_t:s0 nametype=PARENT cap_fp=none cap_fi=none cap_fe=0 cap_fver=0 type=PATH msg=audit(03/12/2018 02:24:39.813:314) : item=0 name=test inode=18112 dev=00:27 mode=file,700 ouid=root ogid=root rdev=00:00 obj=unconfined_u:object_r:user_tmp_t:s0 nametype=NORMAL cap_fp=none cap_fi=none cap_fe=0 cap_fver=0 type=CWD msg=audit(03/12/2018 02:24:39.813:314) : cwd=/tmp type=SYSCALL msg=audit(03/12/2018 02:24:39.813:314) : arch=x86_64 syscall=linkat success=no exit=EPERM(Operation not permitted) a0=0xff9c a1=0x7ffccba77629 a2=0xff9c a3=0x7ffccba7762e items=2 ppid=605 pid=638 auid=rgb uid=rgb gid=rgb euid=rgb suid=rgb fsuid=rgb egid=rgb sgid=rgb fsgid=rgb tty=pts0 ses=4 comm=ln exe=/usr/bin/ln subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 key=(null) type=ANOM_LINK msg=audit(03/12/2018 02:24:39.813:314) : op=linkat ppid=605 pid=638 auid=rgb uid=rgb gid=rgb euid=rgb suid=rgb fsuid=rgb egid=rgb sgid=rgb fsgid=rgb tty=pts0 ses=4 comm=ln exe=/usr/bin/ln subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 res=no See: https://github.com/linux-audit/audit-kernel/issues/21 See also: https://github.com/linux-audit/audit-kernel/issues/51 Richard Guy Briggs (4): audit: make ANOM_LINK obey audit_enabled and audit_dummy_context audit: link denied should not directly generate PATH record audit: add refused symlink to audit_names audit: add parent of refused symlink to audit_names fs/namei.c| 5 +++-- include/linux/audit.h | 9 + kernel/audit.c| 43 --- 3 files changed, 40 insertions(+), 17 deletions(-) -- 1.8.3.1
Re: [PATCH v4.16-rc4 1/1] x86/vdso: on Intel, VDSO should handle CLOCK_MONOTONIC_RAW
Hi Jason, Thank you for the patch! Yet something to improve: [auto build test ERROR on v4.16-rc4] url: https://github.com/0day-ci/linux/commits/Jason-Vas-Dias/x86-vdso-on-Intel-VDSO-should-handle-CLOCK_MONOTONIC_RAW/20180312-141707 config: i386-randconfig-x006-201810 (attached as .config) compiler: gcc-7 (Debian 7.3.0-1) 7.3.0 reproduce: # save the attached .config to linux build tree make ARCH=i386 All errors (new ones prefixed by >>): >> arch/x86/entry/vdso/vdso32.so.dbg: undefined symbols found --- 0-DAY kernel test infrastructureOpen Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation .config.gz Description: application/gzip
Re: [PATCH] scsi: eata: drop VLA in reorder()
On Mon, 12 Mar 2018 14:08:34 +1100, "Tobin C. Harding" said: > removal patch that 768 was a lot of stack space. That comment did, > however say 'deep in some transfer call chain'. I don't know what a > 'transfer call chain' (the transfer bit) is but is there some heuristic > we can use to know how deep is deep? Or more to the point, is there some > heuristic we can use to know what is an acceptable amount of stack space > to use? The canonical "why we put kernel stacks on a diet" configuration: Imagine a bunch of ISCSI targets - with IPSec wrapping the connection. Arranged into a software RAID5. With LVM. With encryption on the LV. With XFS on the encrypted LV. And then the in-kernel sharing it out over NFS. With more IPSec wrapping the NFS TCP connection. Oh, and I/O interrupts, just for fun. And most of all of that has to fit their *entire* stack chain into 2 4K pages. Suddenly, that 768 bytes is taking close to 10% of *all* of the stack that all of that call chain has to share. And I see that patch is against scsi/eata.c - which means it can plausibly end up sharing that stack scenario above starting at 'software raid5'. (For bonus points, the alert reader is invited to figure out which stack each of the above actually ends up on. No, it isn't split across enough stacks that taking 768 bytes out of any of them is acceptable.. :) pgpNOPolYrc3M.pgp Description: PGP signature
[PATCH ghak21 V2 2/4] audit: link denied should not directly generate PATH record
Audit link denied events generate duplicate PATH records which disagree in different ways from symlink and hardlink denials. audit_log_link_denied() should not directly generate PATH records. While we're at it, remove the now useless struct path argument. See: https://github.com/linux-audit/audit-kernel/issues/21 Signed-off-by: Richard Guy Briggs --- fs/namei.c| 2 +- include/linux/audit.h | 6 ++ kernel/audit.c| 17 ++--- 3 files changed, 5 insertions(+), 20 deletions(-) diff --git a/fs/namei.c b/fs/namei.c index 9cc91fb..50d2533 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -1011,7 +1011,7 @@ static int may_linkat(struct path *link) if (safe_hardlink_source(inode) || inode_owner_or_capable(inode)) return 0; - audit_log_link_denied("linkat", link); + audit_log_link_denied("linkat"); return -EPERM; } diff --git a/include/linux/audit.h b/include/linux/audit.h index af410d9..75d5b03 100644 --- a/include/linux/audit.h +++ b/include/linux/audit.h @@ -146,8 +146,7 @@ extern void audit_log_d_path(struct audit_buffer *ab, const struct path *path); extern voidaudit_log_key(struct audit_buffer *ab, char *key); -extern voidaudit_log_link_denied(const char *operation, - const struct path *link); +extern voidaudit_log_link_denied(const char *operation); extern voidaudit_log_lost(const char *message); extern int audit_log_task_context(struct audit_buffer *ab); @@ -194,8 +193,7 @@ static inline void audit_log_d_path(struct audit_buffer *ab, { } static inline void audit_log_key(struct audit_buffer *ab, char *key) { } -static inline void audit_log_link_denied(const char *string, -const struct path *link) +static inline void audit_log_link_denied(const char *string) { } static inline int audit_log_task_context(struct audit_buffer *ab) { diff --git a/kernel/audit.c b/kernel/audit.c index 7026d69..e54deaf 100644 --- a/kernel/audit.c +++ b/kernel/audit.c @@ -2301,36 +2301,23 @@ void audit_log_task_info(struct audit_buffer *ab, struct task_struct *tsk) /** * audit_log_link_denied - report a link restriction denial * @operation: specific link operation - * @link: the path that triggered the restriction */ -void audit_log_link_denied(const char *operation, const struct path *link) +void audit_log_link_denied(const char *operation) { struct audit_buffer *ab; - struct audit_names *name; if (!audit_enabled || audit_dummy_context()) return; - name = kzalloc(sizeof(*name), GFP_NOFS); - if (!name) - return; - /* Generate AUDIT_ANOM_LINK with subject, operation, outcome. */ ab = audit_log_start(current->audit_context, GFP_KERNEL, AUDIT_ANOM_LINK); if (!ab) - goto out; + return; audit_log_format(ab, "op=%s", operation); audit_log_task_info(ab, current); audit_log_format(ab, " res=0"); audit_log_end(ab); - - /* Generate AUDIT_PATH record with object. */ - name->type = AUDIT_TYPE_NORMAL; - audit_copy_inode(name, link->dentry, d_backing_inode(link->dentry)); - audit_log_name(current->audit_context, name, link, 0, NULL); -out: - kfree(name); } /** -- 1.8.3.1
[PATCH ghak21 V2 4/4] audit: add parent of refused symlink to audit_names
Audit link denied events for symlinks were missing the parent PATH record. Add it. Since the full pathname may not be available, reconstruct it from the path in the nameidata supplied. See: https://github.com/linux-audit/audit-kernel/issues/21 Signed-off-by: Richard Guy Briggs --- fs/namei.c| 2 +- include/linux/audit.h | 3 +++ kernel/audit.c| 31 +++ 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/fs/namei.c b/fs/namei.c index 00f5041..2f39617 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -946,7 +946,7 @@ static inline int may_follow_link(struct nameidata *nd) return -ECHILD; audit_inode(nd->name, nd->stack[0].link.dentry, 0); - audit_log_link_denied("follow_link", &nd->stack[0].link); + audit_log_symlink_denied(&nd->stack[0].link); return -EACCES; } diff --git a/include/linux/audit.h b/include/linux/audit.h index 75d5b03..b5808e9 100644 --- a/include/linux/audit.h +++ b/include/linux/audit.h @@ -147,6 +147,7 @@ extern void audit_log_d_path(struct audit_buffer *ab, extern voidaudit_log_key(struct audit_buffer *ab, char *key); extern voidaudit_log_link_denied(const char *operation); +extern voidaudit_log_symlink_denied(const struct path *link); extern voidaudit_log_lost(const char *message); extern int audit_log_task_context(struct audit_buffer *ab); @@ -195,6 +196,8 @@ static inline void audit_log_key(struct audit_buffer *ab, char *key) { } static inline void audit_log_link_denied(const char *string) { } +static inline void audit_log_symlink_denied(const struct path *link) +{ } static inline int audit_log_task_context(struct audit_buffer *ab) { return 0; diff --git a/kernel/audit.c b/kernel/audit.c index e54deaf..4acf374 100644 --- a/kernel/audit.c +++ b/kernel/audit.c @@ -73,6 +73,7 @@ #include #include #include +#include /* for LOOKUP_PARENT */ #include "audit.h" @@ -2320,6 +2321,36 @@ void audit_log_link_denied(const char *operation) audit_log_end(ab); } +/* + * audit_log_symlink_denied - report a symlink restriction denial + * @link: the path that triggered the restriction + */ +void audit_log_symlink_denied(const struct path *link) +{ + char *pathname; + struct filename *filename; + + if (audit_dummy_context()) + return; + + pathname = kmalloc(PATH_MAX + 1, GFP_KERNEL); + if (!pathname) { + audit_panic("memory allocation error while reporting symlink denied"); + return; + } + filename = getname_kernel(d_absolute_path(link, pathname, PATH_MAX + 1)); + if (IS_ERR(filename)) { + audit_panic("error getting pathname while reporting symlink denied"); + goto out; + } + audit_inode(filename, link->dentry->d_parent, LOOKUP_PARENT); + audit_log_link_denied("follow_link"); + putname(filename); +out: + kfree(pathname); + return; +} + /** * audit_log_end - end one audit record * @ab: the audit_buffer -- 1.8.3.1
[PATCH ghak21 V2 3/4] audit: add refused symlink to audit_names
Audit link denied events for symlinks had duplicate PATH records rather than just updating the existing PATH record. Update the symlink's PATH record with the current dentry and inode information. See: https://github.com/linux-audit/audit-kernel/issues/21 Signed-off-by: Richard Guy Briggs --- fs/namei.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/namei.c b/fs/namei.c index 50d2533..00f5041 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -945,6 +945,7 @@ static inline int may_follow_link(struct nameidata *nd) if (nd->flags & LOOKUP_RCU) return -ECHILD; + audit_inode(nd->name, nd->stack[0].link.dentry, 0); audit_log_link_denied("follow_link", &nd->stack[0].link); return -EACCES; } -- 1.8.3.1
Re: [PATCH] device_handler: remove VLAs
On 03/09/2018 11:32 PM, Stephen Kitt wrote: > In preparation to enabling -Wvla, remove VLAs and replace them with > fixed-length arrays instead. > > scsi_dh_{alua,emc,rdac} use variable-length array declarations to > store command blocks, with the appropriate size as determined by > COMMAND_SIZE. This patch replaces these with fixed-sized arrays using > MAX_COMMAND_SIZE, so that the array size can be determined at compile > time. > > This was prompted by https://lkml.org/lkml/2018/3/7/621 > > Signed-off-by: Stephen Kitt > --- > drivers/scsi/device_handler/scsi_dh_alua.c | 8 > drivers/scsi/device_handler/scsi_dh_emc.c | 2 +- > drivers/scsi/device_handler/scsi_dh_rdac.c | 2 +- > 3 files changed, 6 insertions(+), 6 deletions(-) > Reviewed-by: Hannes Reinecke Cheers, Hannes -- Dr. Hannes ReineckeTeamlead Storage & Networking h...@suse.de +49 911 74053 688 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton HRB 21284 (AG Nürnberg)
Re: [PATCH v2 2/2] riscv/atomic: Strengthen implementations with fences
On Fri, Mar 09, 2018 at 04:21:37PM -0800, Daniel Lustig wrote: > On 3/9/2018 2:57 PM, Palmer Dabbelt wrote: > > On Fri, 09 Mar 2018 13:30:08 PST (-0800), parri.and...@gmail.com wrote: > >> On Fri, Mar 09, 2018 at 10:54:27AM -0800, Palmer Dabbelt wrote: > >>> On Fri, 09 Mar 2018 10:36:44 PST (-0800), parri.and...@gmail.com wrote: > >> > >> [...] > >> > >>> >This proposal relies on the generic definition, > >>> > > >>> > include/linux/atomic.h , > >>> > > >>> >and on the > >>> > > >>> > __atomic_op_acquire() > >>> > __atomic_op_release() > >>> > > >>> >above to build the acquire/release atomics (except for the xchg,cmpxchg, > >>> >where the ACQUIRE_BARRIER is inserted conditionally/on success). > >>> > >>> I thought we wanted to use the AQ and RL bits for AMOs, just not for LR/SC > >>> sequences. IIRC the AMOs are safe with the current memory model, but I > >>> might > >>> just have some version mismatches in my head. > >> > >> AMO.aqrl are "safe" w.r.t. the LKMM (as they provide "full-ordering"); > >> OTOH, > >> AMO.aq and AMO.rl present weaknesses that LKMM (and some kernel developers) > >> do not "expect". I was probing this issue in: > >> > >> https://marc.info/?l=linux-kernel&m=151930201102853&w=2 > >> > >> (c.f., e.g., test "RISCV-unlock-lock-read-ordering" from that post). > >> > >> Quoting from the commit message of my patch 1/2: > >> > >> "Referring to the "unlock-lock-read-ordering" test reported below, > >> Daniel wrote: > >> > >> I think an RCpc interpretation of .aq and .rl would in fact > >> allow the two normal loads in P1 to be reordered [...] > >> > >> [...] > >> > >> Likewise even if the unlock()/lock() is between two stores. > >> A control dependency might originate from the load part of > >> the amoswap.w.aq, but there still would have to be something > >> to ensure that this load part in fact performs after the store > >> part of the amoswap.w.rl performs globally, and that's not > >> automatic under RCpc. > >> > >> Simulation of the RISC-V memory consistency model confirmed this > >> expectation." > >> > >> I have just (re)checked these observations against the latest > >> specification, > >> and my results _confirmed_ these verdicts. > > > > Thanks, I must have just gotten confused about a draft spec or something. > > I'm > > pulling these on top or your other memory model related patch. I've renamed > > the branch "next-mm" to be a bit more descriptiove. > > (Sorry for being out of the loop this week, I was out to deal with > a family matter.) > > I assume you're using the herd model? Luc's doing a great job with > that, but even so, nothing is officially confirmed until we ratify > the model. In other words, the herd model may end up changing too. > If something is broken on our end, there's still time to fix it. > > Regarding AMOs, let me copy from something I wrote in a previous > offline conversation: > > > it seems to us that pairing a store-release of "amoswap.rl" with > > a "ld; fence r,rw" doesn't actually give us the RC semantics we've > > been discussing for LKMM. For example: > > > > (a) sd t0,0(s0) > > (b) amoswap.d.rl x0,t1,0(s1) > > ... > > (c) ld a0,0(s1) > > (d) fence r,rw > > (e) sd t2,0(s2) > > > > There, we won't get (a) ordered before (e) regardless of whether > > (b) is RCpc or RCsc. Do you agree? > > At the moment, only the load part of (b) is in the predecessor > set of (d), but the store part of (b) is not. Likewise, the > .rl annotation applies only to the store part of (b), not the > load part. > > This gets back to a question Linus asked last week about > whether the AMO is a single unit or whether it can be You mean AMO or RmW atomic operations? > considered to split into a load and a store part (which still > perform atomically). For RISC-V, for right now at least, the > answer is the latter. Is it still the latter for Linux too? > I think for RmW atomics it's still the latter, the acquire or release is for the load part or the store part of an RmW. For example, ppc uses lwsync as acquire/release barriers, and lwsync could not order write->read. Regards, Boqun > https://lkml.org/lkml/2018/2/26/606 > > > So I think we'll need to make sure we pair .rl with .aq, or that > > we pair fence-based mappings with fence-based mappings, in order > > to make the acquire/release operations work. > > This assumes we'll say that .aq and .rl are RCsc, not RCpc. > But in this case, I think .aq and .rl could still be safe to use, > as long as you don't ever try to mix in a fence-based mapping > on the same data structure like in the example above. That > might be important if we want to find the most compact legal > implementation, and hence do want to use .aq and .rl after all. > > > And since we don't have native "ld.aq" today in RISC-V, that > > would mean smp_store_release would have to remain implemented > > as "fence rw,w; s{w|d}", rather than "amoswap.{w|d}.rl", for
Re: [PATCH v2] staging: vchiq_arm: Clear VLA warning
On Mon, Mar 12, 2018 at 06:58:04AM +0100, Stefan Wahren wrote: > Hi Tobin, > > > "Tobin C. Harding" hat am 12. März 2018 um 06:46 > > geschrieben: > > > > > > On Mon, Mar 12, 2018 at 12:37:53PM +1100, Tobin C. Harding wrote: > > > The kernel would like to have all stack VLA usage removed[1]. The array > > > here is fixed (declared with a const variable) but it appears like a VLA > > > to the compiler. Also, currently we are putting 768 bytes on the > > > stack. This function is only called on the error path so performance is > > > not critical, let's just allocate the memory instead of using the > > > stack. This saves stack space and removes the VLA build warning. > > > > > > kmalloc a buffer for dumping state instead of using the stack. > > > > > > [1]: https://lkml.org/lkml/2018/3/7/621 > > > > > > Signed-off-by: Tobin C. Harding > > > --- > > > > Drop this please, leaks memory. > > except from the leak, did you test this patch on a RPi? No I didn't, but I can have a go at it. Will try before doing v3. thanks, Tobin.
RE: [PATCH v7] staging: typec: handle vendor defined part and modify drp toggling flow
Hi > -Original Message- > From: 李書帆 [mailto:leechu...@gmail.com] > Sent: 2018年3月12日 13:22 > To: Jun Li > Cc: Greg Kroah-Hartman ; > heikki.kroge...@linux.intel.com; li...@roeck-us.net; g...@kroah.com; > shufan_...@richtek.com; cy_hu...@richtek.com; > linux-kernel@vger.kernel.org; linux-...@vger.kernel.org > Subject: Re: [PATCH v7] staging: typec: handle vendor defined part and modify > drp toggling flow > > Hi Jun, > > Thank you. > > 2018-03-12 12:33 GMT+08:00 Jun Li : > > Hi, > > > >> +static irqreturn_t _tcpci_irq(int irq, void *dev_id) { > >> + struct tcpci *tcpci = dev_id; > >> + > >> + return tcpci_irq(tcpci); > >> +} > >> > > ... > > > >> + err = devm_request_threaded_irq(&client->dev, client->irq, NULL, > >> + _tcpci_irq, > >> IRQF_ONESHOT | > IRQF_TRIGGER_LOW, > >> - dev_name(tcpci->dev), tcpci); > >> + dev_name(&client->dev), chip); > > > > - dev_name(&client->dev), chip); > > + dev_name(&client->dev), chip->tcpci); > > > > Did you ever test this patch? > I've tested this patch with tcpci_rt1711h.c that will be sent out for > reviewing in > the next patch after tcpci's modification is passed. > Because interrupt handler is registered in tcpci_rt1711h.c, here is the place > I > didn't notice. Understood. > The interrupt handler for tcpci.c should be modified as following: > static irqreturn_t _tcpci_irq(int irq, void *dev_id) { > - struct tcpci *tcpci = dev_id; > + struct tcpci_chip *chip = dev_id; > > - return tcpci_irq(tcpci); > + return tcpci_irq(chip->tcpci); > } > Either way is OK to fix it. You may send out your v8 and notify Greg to drop your v7 version. Jun Li
Re: [PATCH v2] staging: vchiq_arm: Clear VLA warning
Hi Tobin, > "Tobin C. Harding" hat am 12. März 2018 um 06:46 geschrieben: > > > On Mon, Mar 12, 2018 at 12:37:53PM +1100, Tobin C. Harding wrote: > > The kernel would like to have all stack VLA usage removed[1]. The array > > here is fixed (declared with a const variable) but it appears like a VLA > > to the compiler. Also, currently we are putting 768 bytes on the > > stack. This function is only called on the error path so performance is > > not critical, let's just allocate the memory instead of using the > > stack. This saves stack space and removes the VLA build warning. > > > > kmalloc a buffer for dumping state instead of using the stack. > > > > [1]: https://lkml.org/lkml/2018/3/7/621 > > > > Signed-off-by: Tobin C. Harding > > --- > > Drop this please, leaks memory. except from the leak, did you test this patch on a RPi? Thanks Stefan > > thanks, > Tobin.
Re: [PATCH V2] ZBOOT: fix stack protector in compressed boot phase
Hi Huacai, I love your patch! Yet something to improve: [auto build test ERROR on linus/master] [also build test ERROR on v4.16-rc5 next-20180309] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Huacai-Chen/ZBOOT-fix-stack-protector-in-compressed-boot-phase/20180312-114651 config: sh-allnoconfig (attached as .config) compiler: sh4-linux-gnu-gcc (Debian 7.2.0-11) 7.2.0 reproduce: wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree make.cross ARCH=sh All errors (new ones prefixed by >>): arch/sh/boot/compressed/head_32.S: Assembler messages: >> arch/sh/boot/compressed/head_32.S:79: Error: pcrel too far >> arch/sh/boot/compressed/head_32.S:80: Error: offset out of range >> arch/sh/boot/compressed/head_32.S:80: Error: value of 658943 too large for >> field of 2 bytes at 102 vim +79 arch/sh/boot/compressed/head_32.S 12 13 .global startup 14 startup: 15 /* Load initial status register */ 16 mov.l init_sr, r1 17 ldc r1, sr 18 19 /* Move myself to proper location if necessary */ 20 mova1f, r0 21 mov.l 1f, r2 22 cmp/eq r2, r0 23 bt clear_bss 24 sub r0, r2 25 mov.l bss_start_addr, r0 26 mov #0xffe0, r1 27 and r1, r0 ! align cache line 28 mov.l text_start_addr, r3 29 mov r0, r1 30 sub r2, r1 31 3: 32 mov.l @r1, r4 33 mov.l @(4,r1), r5 34 mov.l @(8,r1), r6 35 mov.l @(12,r1), r7 36 mov.l @(16,r1), r8 37 mov.l @(20,r1), r9 38 mov.l @(24,r1), r10 39 mov.l @(28,r1), r11 40 mov.l r4, @r0 41 mov.l r5, @(4,r0) 42 mov.l r6, @(8,r0) 43 mov.l r7, @(12,r0) 44 mov.l r8, @(16,r0) 45 mov.l r9, @(20,r0) 46 mov.l r10, @(24,r0) 47 mov.l r11, @(28,r0) 48 #ifdef CONFIG_CPU_SH4 49 ocbwb @r0 50 #endif 51 cmp/hi r3, r0 52 add #-32, r0 53 bt/s3b 54 add#-32, r1 55 mov.l 2f, r0 56 jmp @r0 57 nop 58 59 .align 2 60 1: .long 1b 61 2: .long clear_bss 62 text_start_addr: 63 .long startup 64 65 /* Clear BSS */ 66 clear_bss: 67 mov.l end_addr, r1 68 mov.l bss_start_addr, r2 69 mov #0, r0 70 l1: 71 mov.l r0, @-r1 72 cmp/eq r1,r2 73 bf l1 74 75 /* Set the initial pointer. */ 76 mov.l init_stack_addr, r0 77 mov.l @r0, r15 78 > 79 mov.l __stack_chk_guard, r0 > 80 mov #0x000a0dff, r1 --- 0-DAY kernel test infrastructureOpen Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation .config.gz Description: application/gzip
Re: [PATCH 0/2] mtd: use put_device() if device_register fail
On Monday 12 March 2018 01:05 AM, Richard Weinberger wrote: Am Freitag, 9. März 2018, 11:50:47 CET schrieb Arvind Yadav: if device_register() returned an error! Always use put_device() to give up the reference initialized. Arvind Yadav (2): [PATCH 1/2] mtd: use put_device() if device_register fail [PATCH 2/2] mtd: ubi: use put_device() if device_register fail Uhh, this is not obvious. Does device_register() really always return with a reference held in all (error) cases? Thanks, //richard if device_register() returned an error! Always use put_device() to give up the reference initialized.(-- Please see the comment for device_register() ). put_device() is able to handle those case where it'll not return a reference. ~arvind
Re: [PATCH v2] staging: vchiq_arm: Clear VLA warning
On Mon, Mar 12, 2018 at 12:37:53PM +1100, Tobin C. Harding wrote: > The kernel would like to have all stack VLA usage removed[1]. The array > here is fixed (declared with a const variable) but it appears like a VLA > to the compiler. Also, currently we are putting 768 bytes on the > stack. This function is only called on the error path so performance is > not critical, let's just allocate the memory instead of using the > stack. This saves stack space and removes the VLA build warning. > > kmalloc a buffer for dumping state instead of using the stack. > > [1]: https://lkml.org/lkml/2018/3/7/621 > > Signed-off-by: Tobin C. Harding > --- Drop this please, leaks memory. thanks, Tobin.
[PATCH v4.16-rc4 2/2] x86/vdso: on Intel, VDSO should handle CLOCK_MONOTONIC_RAW
Currently the VDSO does not handle clock_gettime( CLOCK_MONOTONIC_RAW, &ts ) on Intel / AMD - it calls vdso_fallback_gettime() for this clock, which issues a syscall, having an unacceptably high latency (minimum measurable time or time between measurements) of 300-700ns on 2 2.8-3.9ghz Haswell x86_64 Family'_'Model : 06_3C machines under various versions of Linux. Sometimes, particularly when correlating elapsed time to performance counter values, code needs to know elapsed time from the perspective of the CPU no matter how "hot" / fast or "cold" / slow it might be running wrt NTP / PTP ; when code needs this, the latencies with a syscall are often unacceptably high. I reported this as Bug #198161 : 'https://bugzilla.kernel.org/show_bug.cgi?id=198961' and in previous posts with subjects matching 'CLOCK_MONOTONIC_RAW' . This patch handles CLOCK_MONOTONIC_RAW clock_gettime() in the VDSO , by exporting the raw clock calibration, last cycles, last xtime_nsec, and last raw_sec value in the vsyscall_gtod_data during vsyscall_update() . Now the new do_monotonic_raw() function in the vDSO has a latency of @ 24ns on average, and the test program: tools/testing/selftest/timers/inconsistency-check.c succeeds with arguments: '-c 4 -t 120' or any arbitrary -t value. The patch is against Linus' latest 4.16-rc5 tree, current HEAD of : git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git . This patch affects only files: arch/x86/include/asm/vgtod.h arch/x86/entry/vdso/vclock_gettime.c arch/x86/entry/vdso/vdso.lds.S arch/x86/entry/vdso/vdsox32.lds.S arch/x86/entry/vdso/vdso32/vdso32.lds.S arch/x86/entry/vsyscall/vsyscall_gtod.c This is a second patch in the series, which adds a record of the calibrated tsc frequency to the VDSO, and a new header: uapi/asm/vdso_tsc_calibration.h which defines a structure : struct linux_tsc_calibration { u32 tsc_khz, mult, shift ; }; and a getter function in the VDSO that can optionally be used by user-space code to implement sub-nanosecond precision clocks . This second patch is entirely optional but I think greatly expands the scope of user-space TSC readers . Oops, previous version of this second patch mistakenly copied the changed part of vclock_gettime.c. Best Regards, Jason Vas Dias . diff -up linux-4.16-rc5/arch/x86/entry/vdso/vclock_gettime.c.4.16-rc5-p1 linux-4.16-rc5/arch/x86/entry/vdso/vclock_gettime.c --- linux-4.16-rc5/arch/x86/entry/vdso/vclock_gettime.c.4.16-rc5-p1 2018-03-12 04:29:27.296982872 + +++ linux-4.16-rc5/arch/x86/entry/vdso/vclock_gettime.c 2018-03-12 05:38:53.019891195 + @@ -21,6 +21,7 @@ #include #include #include +#include #define gtod (&VVAR(vsyscall_gtod_data)) @@ -385,3 +386,22 @@ notrace time_t __vdso_time(time_t *t) } time_t time(time_t *t) __attribute__((weak, alias("__vdso_time"))); + +extern unsigned +__vdso_linux_tsc_calibration(struct linux_tsc_calibration *); + +notraceunsigned +__vdso_linux_tsc_calibration(struct linux_tsc_calibration *tsc_cal) +{ + if ( (gtod->vclock_mode == VCLOCK_TSC) && (tsc_cal != ((void*)0UL)) ) + { + tsc_cal -> tsc_khz = gtod->tsc_khz; + tsc_cal -> mult= gtod->raw_mult; + tsc_cal -> shift = gtod->raw_shift; + return 1; + } + return 0; +} + +unsigned linux_tsc_calibration(void) + __attribute((weak, alias("__vdso_linux_tsc_calibration"))); diff -up linux-4.16-rc5/arch/x86/entry/vdso/vdso.lds.S.4.16-rc5-p1 linux-4.16-rc5/arch/x86/entry/vdso/vdso.lds.S --- linux-4.16-rc5/arch/x86/entry/vdso/vdso.lds.S.4.16-rc5-p1 2018-03-12 00:25:09.0 + +++ linux-4.16-rc5/arch/x86/entry/vdso/vdso.lds.S 2018-03-12 05:18:36.380673342 + @@ -25,6 +25,8 @@ VERSION { __vdso_getcpu; time; __vdso_time; + linux_tsc_calibration; + __vdso_linux_tsc_calibration; local: *; }; } diff -up linux-4.16-rc5/arch/x86/entry/vdso/vdso32/vdso32.lds.S.4.16-rc5-p1 linux-4.16-rc5/arch/x86/entry/vdso/vdso32/vdso32.lds.S --- linux-4.16-rc5/arch/x86/entry/vdso/vdso32/vdso32.lds.S.4.16-rc5-p1 2018-03-12 00:25:09.0 + +++ linux-4.16-rc5/arch/x86/entry/vdso/vdso32/vdso32.lds.S 2018-03-12 05:19:10.765022295 + @@ -26,6 +26,7 @@ VERSION __vdso_clock_gettime; __vdso_gettimeofday; __vdso_time; + __vdso_linux_tsc_calibration; }; LINUX_2.5 { diff -up linux-4.16-rc5/arch/x86/entry/vdso/vdsox32.lds.S.4.16-rc5-p1 linux-4.16-rc5/arch/x86/entry/vdso/vdsox32.lds.S --- linux-4.16-rc5/arch/x86/entry/vdso/vdsox32.lds.S.4.16-rc5-p1 2018-03-12 00:25:09.0 + +++ linux-4.16-rc5/arch/x86/entry/vdso/vdsox32.lds.S2018-03-12 05:18:51.626827852 + @@ -21,6 +
Re: smp_mb__after_spinlock requirement too strong?
On Sun, Mar 11, 2018 at 03:55:41PM +0800, 焦晓冬 wrote: > Peter pointed out in this patch https://patchwork.kernel.org/patch/9771921/ > that the spinning-lock used at __schedule() should be RCsc to ensure > visibility of writes prior to __schedule when the task is to be migrated to > another CPU. > > And this is emphasized at the comment of the newly introduced > smp_mb__after_spinlock(), > > * This barrier must provide two things: > * > * - it must guarantee a STORE before the spin_lock() is ordered against a > * LOAD after it, see the comments at its two usage sites. > * > * - it must ensure the critical section is RCsc. > * > * The latter is important for cases where we observe values written by other > * CPUs in spin-loops, without barriers, while being subject to scheduling. > * > * CPU0 CPU1CPU2 > * > * for (;;) { > *if (READ_ONCE(X)) > * break; > * } > * X=1 > * > * > * r = X; > * > * without transitivity it could be that CPU1 observes X!=0 breaks the loop, > * we get migrated and CPU2 sees X==0. > > which is used at, > > __schedule(bool preempt) { > ... > rq_lock(rq, &rf); > smp_mb__after_spinlock(); > ... > } > . > > If I didn't miss something, I found this kind of visibility is __not__ > necessarily > depends on the spinning-lock at __schedule being RCsc. > > In fact, as for runnable task A, the migration would be, > > CPU0 CPU1CPU2 > > > > lock(rq0) > schedule out A > unock(rq0) > > lock(rq0) > remove A from rq0 > unlock(rq0) > > lock(rq2) > add A into rq2 > unlock(rq2) > lock(rq2) > schedule in A > unlock(rq2) > > > > happens-before > unlock(rq0) happends-before > lock(rq0) happends-before > unlock(rq2) happens-before > lock(rq2) happens-before > > But without RCsc lock, you cannot guarantee that a write propagates to CPU 0 and CPU 2 at the same time, so the same write may propagate to CPU0 before but propagate to CPU 2 after . So.. Regards, Boqun > And for stopped tasks, > > CPU0 CPU1CPU2 > > > > lock(rq0) > schedule out A > remove A from rq0 > store-release(A->on_cpu) > unock(rq0) > > load_acquire(A->on_cpu) > set_task_cpu(A, 2) > > lock(rq2) > add A into rq2 > unlock(rq2) > > lock(rq2) > schedule in A > unlock(rq2) > > > > happens-before > store-release(A->on_cpu) happens-before > load_acquire(A->on_cpu) happens-before > unlock(rq2) happens-before > lock(rq2) happens-before > > > So, I think the only requirement to smp_mb__after_spinlock is > to guarantee a STORE before the spin_lock() is ordered > against a LOAD after it. So we could remove the RCsc requirement > to allow more efficient implementation. > > Did I miss something or this RCsc requirement does not really matter? signature.asc Description: PGP signature
[PATCH v4.16-rc4 2/2] x86/vdso: on Intel, VDSO should handle CLOCK_MONOTONIC_RAW
Currently the VDSO does not handle clock_gettime( CLOCK_MONOTONIC_RAW, &ts ) on Intel / AMD - it calls vdso_fallback_gettime() for this clock, which issues a syscall, having an unacceptably high latency (minimum measurable time or time between measurements) of 300-700ns on 2 2.8-3.9ghz Haswell x86_64 Family'_'Model : 06_3C machines under various versions of Linux. Sometimes, particularly when correlating elapsed time to performance counter values, code needs to know elapsed time from the perspective of the CPU no matter how "hot" / fast or "cold" / slow it might be running wrt NTP / PTP ; when code needs this, the latencies with a syscall are often unacceptably high. I reported this as Bug #198161 : 'https://bugzilla.kernel.org/show_bug.cgi?id=198961' and in previous posts with subjects matching 'CLOCK_MONOTONIC_RAW' . This patch handles CLOCK_MONOTONIC_RAW clock_gettime() in the VDSO , by exporting the raw clock calibration, last cycles, last xtime_nsec, and last raw_sec value in the vsyscall_gtod_data during vsyscall_update() . Now the new do_monotonic_raw() function in the vDSO has a latency of @ 24ns on average, and the test program: tools/testing/selftest/timers/inconsistency-check.c succeeds with arguments: '-c 4 -t 120' or any arbitrary -t value. The patch is against Linus' latest 4.16-rc5 tree, current HEAD of : git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git . This patch affects only files: arch/x86/include/asm/vgtod.h arch/x86/entry/vdso/vclock_gettime.c arch/x86/entry/vdso/vdso.lds.S arch/x86/entry/vdso/vdsox32.lds.S arch/x86/entry/vdso/vdso32/vdso32.lds.S arch/x86/entry/vsyscall/vsyscall_gtod.c This is a second patch in the series, which adds a record of the calibrated tsc frequency to the VDSO, and a new header: uapi/asm/vdso_tsc_calibration.h which defines a structure : struct linux_tsc_calibration { u32 tsc_khz, mult, shift ; }; and a getter function in the VDSO that can optionally be used by user-space code to implement sub-nanosecond precision clocks . This second patch is entirely optional but I think greatly expands the scope of user-space TSC readers . Best Regards, Jason Vas Dias . --- diff -up linux-4.16-rc5/arch/x86/entry/vdso/vclock_gettime.c.4.16-rc5-p1 linux-4.16-rc5/arch/x86/entry/vdso/vclock_gettime.c --- linux-4.16-rc5/arch/x86/entry/vdso/vclock_gettime.c.4.16-rc5-p1 2018-03-12 04:29:27.296982872 + +++ linux-4.16-rc5/arch/x86/entry/vdso/vclock_gettime.c 2018-03-12 05:10:53.185158334 + @@ -21,6 +21,7 @@ #include #include #include +#include #define gtod (&VVAR(vsyscall_gtod_data)) @@ -385,3 +386,41 @@ notrace time_t __vdso_time(time_t *t) } time_t time(time_t *t) __attribute__((weak, alias("__vdso_time"))); + +extern unsigned +__vdso_linux_tsc_calibration(struct linux_tsc_calibration *); + +notraceunsigned +__vdso_linux_tsc_calibration(struct linux_tsc_calibration *tsc_cal) +{ + if ( (gtod->vclock_mode == VCLOCK_TSC) && (tsc_cal != ((void*)0UL)) ) + { + tsc_cal -> tsc_khz = gtod->tsc_khz; + tsc_cal -> mult= gtod->raw_mult; + tsc_cal -> shift = gtod->raw_shift; + return 1; + } + return 0; +} + +unsigned linux_tsc_calibration(void) + __attribute((weak, alias("__vdso_linux_tsc_calibration"))); + +extern unsigned +__vdso_linux_tsc_calibration(struct linux_tsc_calibration *); + +notraceunsigned +__vdso_linux_tsc_calibration(struct linux_tsc_calibration *tsc_cal) +{ + if ( (gtod->vclock_mode == VCLOCK_TSC) && (tsc_cal != ((void*)0UL)) ) + { + tsc_cal -> tsc_khz = gtod->tsc_khz; + tsc_cal -> mult= gtod->raw_mult; + tsc_cal -> shift = gtod->raw_shift; + return 1; + } + return 0; +} + +unsigned linux_tsc_calibration(void) + __attribute((weak, alias("__vdso_linux_tsc_calibration"))); diff -up linux-4.16-rc5/arch/x86/entry/vdso/vdso.lds.S.4.16-rc5-p1 linux-4.16-rc5/arch/x86/entry/vdso/vdso.lds.S --- linux-4.16-rc5/arch/x86/entry/vdso/vdso.lds.S.4.16-rc5-p1 2018-03-12 00:25:09.0 + +++ linux-4.16-rc5/arch/x86/entry/vdso/vdso.lds.S 2018-03-12 05:18:36.380673342 + @@ -25,6 +25,8 @@ VERSION { __vdso_getcpu; time; __vdso_time; + linux_tsc_calibration; + __vdso_linux_tsc_calibration; local: *; }; } diff -up linux-4.16-rc5/arch/x86/entry/vdso/vdso32/vdso32.lds.S.4.16-rc5-p1 linux-4.16-rc5/arch/x86/entry/vdso/vdso32/vdso32.lds.S --- linux-4.16-rc5/arch/x86/entry/vdso/vdso32/vdso32.lds.S.4.16-rc5-p1 2018-03-12 00:25:09.0 + +++ linux-4.16-rc5/arch/x86/entry/vdso/vdso32/vdso32.lds.S 2018-03-12 05:19:10.765022295 + @@ -26,6 +26,7 @@ VERSION __vdso_
Re: [PATCH v2] PM / wakeup: use seq_open() to show wakeup stats
Hello, Rafael: 2018-03-05 16:47 GMT+08:00 Ganesh Mahendran : > single_open() interface requires that the whole output must > fit into a single buffer. This will lead to timeout when > system memory is not in a good situation. > > This patch use seq_open() to show wakeup stats. This method > need only one page, so timeout will not be observed. > > Signed-off-by: Ganesh Mahendran > > v2: use srcu_read_lock instead of rcu_read_lock How about the V2 patch? If you have other concern, please let me know. Thanks. > --- > drivers/base/power/wakeup.c | 77 > +++-- > 1 file changed, 61 insertions(+), 16 deletions(-) > > diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c > index ea01621..3bcab7d 100644 > --- a/drivers/base/power/wakeup.c > +++ b/drivers/base/power/wakeup.c > @@ -1029,32 +1029,77 @@ static int print_wakeup_source_stats(struct seq_file > *m, > return 0; > } > > -/** > - * wakeup_sources_stats_show - Print wakeup sources statistics information. > - * @m: seq_file to print the statistics into. > - */ > -static int wakeup_sources_stats_show(struct seq_file *m, void *unused) > +static void *wakeup_sources_stats_seq_start(struct seq_file *m, > + loff_t *pos) > { > struct wakeup_source *ws; > - int srcuidx; > + loff_t n = *pos; > + int *srcuidx = m->private; > > - seq_puts(m, "name\t\tactive_count\tevent_count\twakeup_count\t" > - "expire_count\tactive_since\ttotal_time\tmax_time\t" > - "last_change\tprevent_suspend_time\n"); > + if (n == 0) { > + seq_puts(m, > "name\t\tactive_count\tevent_count\twakeup_count\t" > + "expire_count\tactive_since\ttotal_time\tmax_time\t" > + "last_change\tprevent_suspend_time\n"); > + } > > - srcuidx = srcu_read_lock(&wakeup_srcu); > - list_for_each_entry_rcu(ws, &wakeup_sources, entry) > - print_wakeup_source_stats(m, ws); > - srcu_read_unlock(&wakeup_srcu, srcuidx); > + *srcuidx = srcu_read_lock(&wakeup_srcu); > + list_for_each_entry_rcu(ws, &wakeup_sources, entry) { > + if (n-- > 0) > + continue; > + goto out; > + } > + ws = NULL; > +out: > + return ws; > +} > + > +static void *wakeup_sources_stats_seq_next(struct seq_file *m, > + void *v, loff_t *pos) > +{ > + struct wakeup_source *ws = v; > + struct wakeup_source *next_ws = NULL; > + > + ++(*pos); > > - print_wakeup_source_stats(m, &deleted_ws); > + list_for_each_entry_continue_rcu(ws, &wakeup_sources, entry) { > + next_ws = ws; > + break; > + } > + > + return next_ws; > +} > + > +static void wakeup_sources_stats_seq_stop(struct seq_file *m, void *v) > +{ > + int *srcuidx = m->private; > + > + srcu_read_unlock(&wakeup_srcu, *srcuidx); > +} > + > +/** > + * wakeup_sources_stats_seq_show - Print wakeup sources statistics > information. > + * @m: seq_file to print the statistics into. > + * @v: wakeup_source of each iteration > + */ > +static int wakeup_sources_stats_seq_show(struct seq_file *m, void *v) > +{ > + struct wakeup_source *ws = v; > + > + print_wakeup_source_stats(m, ws); > > return 0; > } > > +static const struct seq_operations wakeup_sources_stats_seq_ops = { > + .start = wakeup_sources_stats_seq_start, > + .next = wakeup_sources_stats_seq_next, > + .stop = wakeup_sources_stats_seq_stop, > + .show = wakeup_sources_stats_seq_show, > +}; > + > static int wakeup_sources_stats_open(struct inode *inode, struct file *file) > { > - return single_open(file, wakeup_sources_stats_show, NULL); > + return seq_open_private(file, &wakeup_sources_stats_seq_ops, > sizeof(int)); > } > > static const struct file_operations wakeup_sources_stats_fops = { > @@ -1062,7 +1107,7 @@ static int wakeup_sources_stats_open(struct inode > *inode, struct file *file) > .open = wakeup_sources_stats_open, > .read = seq_read, > .llseek = seq_lseek, > - .release = single_release, > + .release = seq_release_private, > }; > > static int __init wakeup_sources_debugfs_init(void) > -- > 1.9.1 >
[PATCH] perf: update perf_cgroup time for ancestor cgroup(s)
When a perf_event is attached to parent cgroup, it should count events for all children cgroups: parent_group < perf_event \ - child_group < process(es) However, in our tests, we found this perf_event cannot report reliable results. This is because perf_event->cgrp and cpuctx->cgrp are not identical, thus perf_event->cgrp are not updated properly. This patch fixes this by updating perf_cgroup properly for ancestor cgroup(s). Signed-off-by: Song Liu Reported-by: Ephraim Park --- kernel/events/core.c | 68 +++- 1 file changed, 67 insertions(+), 1 deletion(-) diff --git a/kernel/events/core.c b/kernel/events/core.c index 5789810..623d38f 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -722,11 +722,48 @@ static inline void __update_cgrp_time(struct perf_cgroup *cgrp) info->timestamp = now; } +static inline void +update_ancestor_cgroup_time(struct perf_event *event, + struct perf_cgroup *cgrp, + struct perf_cgroup_info *cgrp_info) +{ + if (!is_cgroup_event(event)) + return; + + if (cgroup_is_descendant(cgrp->css.cgroup, +event->cgrp->css.cgroup) && + event->cgrp != cgrp) { + struct perf_cgroup_info *info; + + info = this_cpu_ptr(event->cgrp->info); + info->time += cgrp_info->timestamp - info->timestamp; + info->timestamp = cgrp_info->timestamp; + } +} + static inline void update_cgrp_time_from_cpuctx(struct perf_cpu_context *cpuctx) { struct perf_cgroup *cgrp_out = cpuctx->cgrp; - if (cgrp_out) + + if (cgrp_out) { __update_cgrp_time(cgrp_out); + + /* update time for ancestor cgroups */ + if (cgrp_out->css.cgroup->level > 1) { + struct perf_cgroup_info *info + = this_cpu_ptr(cgrp_out->info); + struct perf_event *event; + + list_for_each_entry(event, &cpuctx->ctx.pinned_groups, + group_entry) + update_ancestor_cgroup_time(event, cgrp_out, + info); + list_for_each_entry(event, &cpuctx->ctx.flexible_groups, + group_entry) + update_ancestor_cgroup_time(event, cgrp_out, + info); + } + } } static inline void update_cgrp_time_from_event(struct perf_event *event) @@ -749,6 +786,24 @@ static inline void update_cgrp_time_from_event(struct perf_event *event) } static inline void +perf_ancestor_cgroup_set_timestamp(struct perf_event *event, + struct perf_cgroup *cgrp, + struct perf_cgroup_info *cgrp_info) +{ + if (!is_cgroup_event(event)) + return; + + if (cgroup_is_descendant(cgrp->css.cgroup, +event->cgrp->css.cgroup) && + event->cgrp != cgrp) { + struct perf_cgroup_info *info + = this_cpu_ptr(event->cgrp->info); + + info->timestamp = cgrp_info->timestamp; + } +} + +static inline void perf_cgroup_set_timestamp(struct task_struct *task, struct perf_event_context *ctx) { @@ -766,6 +821,17 @@ perf_cgroup_set_timestamp(struct task_struct *task, cgrp = perf_cgroup_from_task(task, ctx); info = this_cpu_ptr(cgrp->info); info->timestamp = ctx->timestamp; + + /* set timestamp for ancestor cgroups */ + if (cgrp->css.cgroup->level > 1) { + struct perf_cgroup_info *info = this_cpu_ptr(cgrp->info); + struct perf_event *event; + + list_for_each_entry(event, &ctx->pinned_groups, group_entry) + perf_ancestor_cgroup_set_timestamp(event, cgrp, info); + list_for_each_entry(event, &ctx->flexible_groups, group_entry) + perf_ancestor_cgroup_set_timestamp(event, cgrp, info); + } } static DEFINE_PER_CPU(struct list_head, cgrp_cpuctx_list); -- 2.9.5
Liebe Freunde
Liebe Freunde Ich habe ein Geschäft von $ 65.400.000.00 Million (fünfundsechzig Millionen, vierhunderttausend US-Dollar), die er in unserer Bank hinterlegt hat und gerade lügt, nicht beansprucht zu teilen, sollten Sie interessiert sein. Sollten Sie interessiert sein, wenden Sie sich bitte an meine private E-Mail-Adresse unten: E-Mail: shiying...@gmail.com Mit freundlichen Grüßen, Dr SHI YING
[PATCH v2 2/3] phy: phy-mtk-tphy: add configurable parameters for slew rate calibrate
There are two parameters, ref_clk and coefficient, for U2 slew rate calibrate which may vary on different SoCs, here allow them to be configurable Signed-off-by: Chunfeng Yun --- drivers/phy/mediatek/phy-mtk-tphy.c | 20 +++- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/drivers/phy/mediatek/phy-mtk-tphy.c b/drivers/phy/mediatek/phy-mtk-tphy.c index 6073c25..38c281b 100644 --- a/drivers/phy/mediatek/phy-mtk-tphy.c +++ b/drivers/phy/mediatek/phy-mtk-tphy.c @@ -306,6 +306,8 @@ struct mtk_tphy { const struct mtk_phy_pdata *pdata; struct mtk_phy_instance **phys; int nphys; + int src_ref_clk; /* MHZ, reference clock for slew rate calibrate */ + int src_coef; /* coefficient for slew rate calibrate */ }; static void hs_slew_rate_calibrate(struct mtk_tphy *tphy, @@ -360,16 +362,17 @@ static void hs_slew_rate_calibrate(struct mtk_tphy *tphy, writel(tmp, fmreg + U3P_U2FREQ_FMMONR1); if (fm_out) { - /* ( 1024 / FM_OUT ) x reference clock frequency x 0.028 */ - tmp = U3P_FM_DET_CYCLE_CNT * U3P_REF_CLK * U3P_SLEW_RATE_COEF; - tmp /= fm_out; + /* ( 1024 / FM_OUT ) x reference clock frequency x coef */ + tmp = tphy->src_ref_clk * tphy->src_coef; + tmp = (tmp * U3P_FM_DET_CYCLE_CNT) / fm_out; calibration_val = DIV_ROUND_CLOSEST(tmp, U3P_SR_COEF_DIVISOR); } else { /* if FM detection fail, set default value */ calibration_val = 4; } - dev_dbg(tphy->dev, "phy:%d, fm_out:%d, calib:%d\n", - instance->index, fm_out, calibration_val); + dev_dbg(tphy->dev, "phy:%d, fm_out:%d, calib:%d (clk:%d, coef:%d)\n", + instance->index, fm_out, calibration_val, + tphy->src_ref_clk, tphy->src_coef); /* set HS slew rate */ tmp = readl(com + U3P_USBPHYACR5); @@ -1041,6 +1044,13 @@ static int mtk_tphy_probe(struct platform_device *pdev) tphy->u3phya_ref = NULL; } + tphy->src_ref_clk = U3P_REF_CLK; + tphy->src_coef = U3P_SLEW_RATE_COEF; + /* update parameters of slew rate calibrate if exist */ + device_property_read_u32(dev, "mediatek,src-ref-clk-mhz", + &tphy->src_ref_clk); + device_property_read_u32(dev, "mediatek,src-coef", &tphy->src_coef); + port = 0; for_each_child_of_node(np, child_np) { struct mtk_phy_instance *instance; -- 1.9.1
[PATCH v2 3/3] dt-bindings: phy-mtk-tphy: add properties for U2 slew rate calibrate
Add two properties of ref_clk and coefficient used by U2 slew rate calibrate which may vary on different SoCs Signed-off-by: Chunfeng Yun --- Documentation/devicetree/bindings/phy/phy-mtk-tphy.txt | 4 1 file changed, 4 insertions(+) diff --git a/Documentation/devicetree/bindings/phy/phy-mtk-tphy.txt b/Documentation/devicetree/bindings/phy/phy-mtk-tphy.txt index 41e09ed..0d34b2b 100644 --- a/Documentation/devicetree/bindings/phy/phy-mtk-tphy.txt +++ b/Documentation/devicetree/bindings/phy/phy-mtk-tphy.txt @@ -27,6 +27,10 @@ Optional properties (controller (parent) node): - reg : offset and length of register shared by multiple ports, exclude port's private register. It is needed on mt2701 and mt8173, but not on mt2712. + - mediatek,src-ref-clk-mhz: frequency of reference clock for slew rate + calibrate + - mediatek,src-coef : coefficient for slew rate calibrate, depends on + SoC process Required properties (port (child) node): - reg : address and length of the register set for the port. -- 1.9.1
[PATCH v2 1/3] phy: phy-mtk-tphy: keep default value of mcu_bus_ck_gate_en
The default value of mcu_bus_ck_gate_en is 1, if clear it, will prevent system to enter deep idle mode, so keep its default value and without affecting PCIe function. Signed-off-by: Chunfeng Yun --- drivers/phy/mediatek/phy-mtk-tphy.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/phy/mediatek/phy-mtk-tphy.c b/drivers/phy/mediatek/phy-mtk-tphy.c index 1e96d07..6073c25 100644 --- a/drivers/phy/mediatek/phy-mtk-tphy.c +++ b/drivers/phy/mediatek/phy-mtk-tphy.c @@ -688,8 +688,7 @@ static void pcie_phy_instance_power_on(struct mtk_tphy *tphy, u32 tmp; tmp = readl(bank->chip + U3P_U3_CHIP_GPIO_CTLD); - tmp &= ~(P3C_FORCE_IP_SW_RST | P3C_MCU_BUS_CK_GATE_EN | - P3C_REG_IP_SW_RST); + tmp &= ~(P3C_FORCE_IP_SW_RST | P3C_REG_IP_SW_RST); writel(tmp, bank->chip + U3P_U3_CHIP_GPIO_CTLD); tmp = readl(bank->chip + U3P_U3_CHIP_GPIO_CTLE); -- 1.9.1
Re: [PATCH] rcu: exp: Fix "must hold exp_mutex" comments for QS reporting functions
On Fri, Mar 09, 2018 at 12:17:07PM -0800, Paul E. McKenney wrote: > On Fri, Mar 09, 2018 at 02:57:00PM +0800, Boqun Feng wrote: > > On Thu, Mar 08, 2018 at 07:42:55AM -0800, Paul E. McKenney wrote: > > > On Thu, Mar 08, 2018 at 04:30:06PM +0800, Boqun Feng wrote: > > > > On Thu, Mar 08, 2018 at 12:54:29PM +0800, Boqun Feng wrote: > > > > > On Wed, Mar 07, 2018 at 08:30:17PM -0800, Paul E. McKenney wrote: > > > > > [...] > > > > > > > > > > > > > > +/* > > > > > > > + * Like sync_rcu_preempt_exp_done(), but this function assumes > > > > > > > the caller > > > > > > > + * doesn't hold the rcu_node's ->lock, and will acquire and > > > > > > > release the lock > > > > > > > + * itself > > > > > > > + */ > > > > > > > +static bool sync_rcu_preempt_exp_done_unlocked(struct rcu_node > > > > > > > *rnp) > > > > > > > +{ > > > > > > > + unsigned long flags; > > > > > > > + bool ret; > > > > > > > + > > > > > > > + raw_spin_lock_irqsave_rcu_node(rnp, flags); > > > > > > > + ret = sync_rcu_preempt_exp_done(rnp); > > > > > > > > > > > > Let's see... The sync_rcu_preempt_exp_done() function checks the > > > > > > ->exp_tasks pointer and the ->expmask bitmask. The number of bits > > > > > > in the > > > > > > mask can only decrease, and the ->exp_tasks pointer can only > > > > > > transition > > > > > > from NULL to non-NULL when there is at least one bit set. However, > > > > > > there is no ordering in sync_rcu_preempt_exp_done(), so it is > > > > > > possible > > > > > > that it could be fooled without the lock: > > > > > > > > > > > > o CPU 0 in sync_rcu_preempt_exp_done() reads ->exp_tasks and > > > > > > sees that it is NULL. > > > > > > > > > > > > o CPU 1 blocks within an RCU read-side critical section, so > > > > > > it enqueues the task and points ->exp_tasks at it and > > > > > > clears CPU 1's bit in ->expmask. > > > > > > > > > > > > o All other CPUs clear their bits in ->expmask. > > > > > > > > > > > > o CPU 0 reads ->expmask, sees that it is zero, so incorrectly > > > > > > concludes that all quiescent states have completed, despite > > > > > > the fact that ->exp_tasks is non-NULL. > > > > > > > > > > > > So it seems to me that the lock is needed. Good catch!!! The > > > > > > problem > > > > > > would occur only if the task running on CPU 0 received a spurious > > > > > > wakeup, but that could potentially happen. > > > > > > > > > > Thanks for the analysis ;-) > > > > > > The other limitation is that it occurs only on systems small enough > > > to have a single-node rcu_node tree. But still... > > > > > > > > > If lock contention becomes a problem, memory-ordering tricks could > > > > > > be > > > > > > applied, but the lock is of course simpler. > > > > > > > > > > > > > > > > Agreed. > > > > > > > > > > > I am guessing that this is a prototype patch, and that you are > > > > > > planning > > > > > > > > > > Yes, this is a prototype. And I'm preparing a proper patch to send > > > > > later. > > > > > > Very good, thank you! > > > > > > > > > to add lockdep annotations in more places, but either way please let > > > > > > me know. > > > > > > > > > > Give it's a bug as per your analysis, I'd like to defer other lockdep > > > > > annotations and send this first. However, I'm currently getting other > > > > > lockdep splats after applying this, so I need to get that sorted > > > > > first. > > > > > > > > Hmm.. the other lockdep splat seems irrelevant with my patch, I could > > > > observe it on mainline using rcutorture with CONFIG_PROVE_LOCKING=y. I'd > > > > spend some more time on it, in the meanwhile, send a proper patch for > > > > this sync_rcu_preempt_exp_done(). > > > > > > I am not seeing that one, but am very interested in getting it fixed! ;-) > > > > Found the root cause, and send out the patch ;-) > > Very good! Still not sure why I don't see it, but as long as it is fixed! > One thing I could hit this is because I ran rcutorture with CONFIG_PROVE_LOCKING=y, maybe you could consider adding that in your rcutorture testsuite? Regards, Boqun > Thanx, Paul > signature.asc Description: PGP signature
Re: [PATCH v7] staging: typec: handle vendor defined part and modify drp toggling flow
Hi Jun, Thank you. 2018-03-12 12:33 GMT+08:00 Jun Li : > Hi, > >> +static irqreturn_t _tcpci_irq(int irq, void *dev_id) { >> + struct tcpci *tcpci = dev_id; >> + >> + return tcpci_irq(tcpci); >> +} >> > ... > >> + err = devm_request_threaded_irq(&client->dev, client->irq, NULL, >> + _tcpci_irq, >> IRQF_ONESHOT | IRQF_TRIGGER_LOW, >> - dev_name(tcpci->dev), tcpci); >> + dev_name(&client->dev), chip); > > - dev_name(&client->dev), chip); > + dev_name(&client->dev), chip->tcpci); > > Did you ever test this patch? I've tested this patch with tcpci_rt1711h.c that will be sent out for reviewing in the next patch after tcpci's modification is passed. Because interrupt handler is registered in tcpci_rt1711h.c, here is the place I didn't notice. The interrupt handler for tcpci.c should be modified as following: static irqreturn_t _tcpci_irq(int irq, void *dev_id) { - struct tcpci *tcpci = dev_id; + struct tcpci_chip *chip = dev_id; - return tcpci_irq(tcpci); + return tcpci_irq(chip->tcpci); } > > I noticed Greg already picked this patch[1]: > [1] > https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git/commit/?h=usb-testing&id=8f94390226487bcb86c554ddc12eef0d27bdec3b > > One more minor comment below. > > Jun Li > >> diff --git a/drivers/staging/typec/tcpci.h b/drivers/staging/typec/tcpci.h >> index >> fdfb06c..a2c1754 100644 >> --- a/drivers/staging/typec/tcpci.h >> +++ b/drivers/staging/typec/tcpci.h >> @@ -59,6 +59,7 @@ >> #define TCPC_POWER_CTRL_VCONN_ENABLE BIT(0) >> >> #define TCPC_CC_STATUS 0x1d >> +#define TCPC_CC_STATUS_DRPRSTBIT(5) > > Defined but not used. This definition can be removed for now. > >> #define TCPC_CC_STATUS_TERM BIT(4) >> #define TCPC_CC_STATUS_CC2_SHIFT 2 >> #define TCPC_CC_STATUS_CC2_MASK 0x3 >> @@ -121,4 +122,18 @@ >> #define TCPC_VBUS_VOLTAGE_ALARM_HI_CFG 0x76 >> #define TCPC_VBUS_VOLTAGE_ALARM_LO_CFG 0x78 >> >> +struct tcpci; >> +struct tcpci_data { >> + struct regmap *regmap; >> + int (*init)(struct tcpci *tcpci, struct tcpci_data *data); >> + int (*set_vconn)(struct tcpci *tcpci, struct tcpci_data *data, >> + bool enable); >> + int (*start_drp_toggling)(struct tcpci *tcpci, struct tcpci_data *data, >> + enum typec_cc_status cc); >> +}; >> + >> +struct tcpci *tcpci_register_port(struct device *dev, struct tcpci_data >> +*data); void tcpci_unregister_port(struct tcpci *tcpci); irqreturn_t >> +tcpci_irq(struct tcpci *tcpci); >> + >> #endif /* __LINUX_USB_TCPCI_H */ >> -- >> 1.9.1 > -- Best Regards, 書帆
Re: [PATCH] rbd: Remove VLA stack usage
On Sun, Mar 11, 2018 at 10:02:04PM -0700, Eric Biggers wrote: > On Mon, Mar 12, 2018 at 03:49:40PM +1100, Tobin C. Harding wrote: > > The kernel would like to have all stack VLA usage removed[1]. > > Can you please stop writing this? The Linux kernel isn't sentient; it doesn't > "like" anything. You need to explain why *you* (and other people) believe > these > changes should be made. No worries, will re-spin with better description. thanks, Tobin.
Re: [PATCH] rbd: Remove VLA stack usage
On Mon, Mar 12, 2018 at 03:49:40PM +1100, Tobin C. Harding wrote: > The kernel would like to have all stack VLA usage removed[1]. Can you please stop writing this? The Linux kernel isn't sentient; it doesn't "like" anything. You need to explain why *you* (and other people) believe these changes should be made. Eric
[PATCH v4.16-rc4 1/2] x86/vdso: on Intel, VDSO should handle CLOCK_MONOTONIC_RAW
Currently the VDSO does not handle clock_gettime( CLOCK_MONOTONIC_RAW, &ts ) on Intel / AMD - it calls vdso_fallback_gettime() for this clock, which issues a syscall, having an unacceptably high latency (minimum measurable time or time between measurements) of 300-700ns on 2 2.8-3.9ghz Haswell x86_64 Family'_'Model : 06_3C machines under various versions of Linux. Sometimes, particularly when correlating elapsed time to performance counter values, code needs to know elapsed time from the perspective of the CPU no matter how "hot" / fast or "cold" / slow it might be running wrt NTP / PTP ; when code needs this, the latencies with a syscall are often unacceptably high. I reported this as Bug #198161 : 'https://bugzilla.kernel.org/show_bug.cgi?id=198961' and in previous posts with subjects matching 'CLOCK_MONOTONIC_RAW' . This patch handles CLOCK_MONOTONIC_RAW clock_gettime() in the VDSO , by exporting the raw clock calibration, last cycles, last xtime_nsec, and last raw_sec value in the vsyscall_gtod_data during vsyscall_update() . Now the new do_monotonic_raw() function in the vDSO has a latency of @ 24ns on average, and the test program: tools/testing/selftest/timers/inconsistency-check.c succeeds with arguments: '-c 4 -t 120' or any arbitrary -t value. The patch is against Linus' latest 4.16-rc5 tree, current HEAD of : git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git . The patch affects only files: arch/x86/include/asm/vgtod.h arch/x86/include/asm/msr.h arch/x86/entry/vdso/vclock_gettime.c arch/x86/entry/vsyscall/vsyscall_gtod.c This is a resend of the original patch fixing issues identified by tglx in mail thread of $subject - mainly that the rdtscp() assembler wrapper function should be in msr.h - it now is. There is a second patch following in a few minutes which adds a record of the calibrated tsc frequency to the VDSO, and a new header: uapi/asm/vdso_tsc_calibration.h which defines a structure : struct linux_tsc_calibration { u32 tsc_khz, mult, shift ; }; and a getter function in the VDSO that can optionally be used by user-space code to implement sub-nanosecond precision clocks . This second patch is entirely optional but I think greatly expands the scope of user-space TSC readers . Best Regards, Jason Vas Dias . --- diff -up linux-4.16-rc5/arch/x86/entry/vdso/vclock_gettime.c.4.16-rc5 linux-4.16-rc5/arch/x86/entry/vdso/vclock_gettime.c --- linux-4.16-rc5/arch/x86/entry/vdso/vclock_gettime.c.4.16-rc5 2018-03-12 00:25:09.0 + +++ linux-4.16-rc5/arch/x86/entry/vdso/vclock_gettime.c 2018-03-12 04:29:27.296982872 + @@ -182,6 +182,19 @@ notrace static u64 vread_tsc(void) return last; } +notrace static u64 vread_tsc_raw(void) +{ + u64 tsc, last=gtod->raw_cycle_last; + if( likely( gtod->has_rdtscp ) ) + tsc = rdtscp((void*)0); +else + tsc = rdtsc_ordered(); + if (likely(tsc >= last)) + return tsc; + asm volatile (""); + return last; +} + notrace static inline u64 vgetsns(int *mode) { u64 v; @@ -203,6 +216,27 @@ notrace static inline u64 vgetsns(int *m return v * gtod->mult; } +notrace static inline u64 vgetsns_raw(int *mode) +{ + u64 v; + cycles_t cycles; + + if (gtod->vclock_mode == VCLOCK_TSC) + cycles = vread_tsc_raw(); +#ifdef CONFIG_PARAVIRT_CLOCK + else if (gtod->vclock_mode == VCLOCK_PVCLOCK) + cycles = vread_pvclock(mode); +#endif +#ifdef CONFIG_HYPERV_TSCPAGE + else if (gtod->vclock_mode == VCLOCK_HVCLOCK) + cycles = vread_hvclock(mode); +#endif + else + return 0; + v = (cycles - gtod->raw_cycle_last) & gtod->raw_mask; + return v * gtod->raw_mult; +} + /* Code size doesn't matter (vdso is 4k anyway) and this is faster. */ notrace static int __always_inline do_realtime(struct timespec *ts) { @@ -246,6 +280,27 @@ notrace static int __always_inline do_mo return mode; } +notrace static int __always_inline do_monotonic_raw( struct timespec *ts) +{ + unsigned long seq; + u64 ns; + int mode; + + do { + seq = gtod_read_begin(gtod); + mode = gtod->vclock_mode; + ts->tv_sec = gtod->monotonic_time_raw_sec; + ns = gtod->monotonic_time_raw_nsec; + ns += vgetsns_raw(&mode); + ns >>= gtod->raw_shift; + } while (unlikely(gtod_read_retry(gtod, seq))); + + ts->tv_sec += __iter_div_u64_rem(ns, NSEC_PER_SEC, &ns); + ts->tv_nsec = ns; + + return mode; +} + notrace static void do_realtime_coarse(struct timespec *ts) { unsigned long seq; @@ -277,6 +332,10 @@ notrace int __vdso_clock_gettime(clockid if (do_monotonic(ts) == VCLOCK_NONE)
[PATCH] rbd: Remove VLA saving ack buffer size
The kernel would like to have all stack VLA usage removed[1]. Here the array is declared using a variable that is declared using a constant statement but the compiler still emits a warning. We can clear the warning bu using the constant statement directly. The buffer size variable is set to zero on the error path; the buffer size variable is used later in the function, we can maintain this behavior by setting the variable using the macro ARRAY_SIZE. Use constant statement to declare array. [1]: https://lkml.org/lkml/2018/3/7/621 Signed-off-by: Tobin C. Harding --- Excuse the lack of threading, I forgot the second patch ;) Can re-send threaded correctly if required. drivers/block/rbd.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index 927ecd9a2511..7c228753fddd 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -3618,13 +3618,14 @@ static void __rbd_acknowledge_notify(struct rbd_device *rbd_dev, u64 notify_id, u64 cookie, s32 *result) { struct ceph_osd_client *osdc = &rbd_dev->rbd_client->client->osdc; - int buf_size = 4 + CEPH_ENCODING_START_BLK_LEN; - char buf[buf_size]; + char buf[4 + CEPH_ENCODING_START_BLK_LEN]; + int buf_size; int ret; if (result) { void *p = buf; + buf_size = ARRAY_SIZE(buf); /* encode ResponseMessage */ ceph_start_encoding(&p, 1, 1, buf_size - CEPH_ENCODING_START_BLK_LEN); -- 2.7.4
[PATCH] rbd: Remove VLA stack usage
The kernel would like to have all stack VLA usage removed[1]. Here the array is declared using a variable that is declared using a constant statement but the compiler still emits a warning. We can clear the warning bu using the constant statement directly. In place of later usage of the size variable we can use the ARRAY_SIZE() macro. Use constant statement to declare array. [1]: https://lkml.org/lkml/2018/3/7/621 Signed-off-by: Tobin C. Harding --- drivers/block/rbd.c | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index 0016170cde0a..927ecd9a2511 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -3100,20 +3100,19 @@ static int __rbd_notify_op_lock(struct rbd_device *rbd_dev, { struct ceph_osd_client *osdc = &rbd_dev->rbd_client->client->osdc; struct rbd_client_id cid = rbd_get_cid(rbd_dev); - int buf_size = 4 + 8 + 8 + CEPH_ENCODING_START_BLK_LEN; - char buf[buf_size]; + char buf[4 + 8 + 8 + CEPH_ENCODING_START_BLK_LEN]; void *p = buf; dout("%s rbd_dev %p notify_op %d\n", __func__, rbd_dev, notify_op); /* encode *LockPayload NotifyMessage (op + ClientId) */ - ceph_start_encoding(&p, 2, 1, buf_size - CEPH_ENCODING_START_BLK_LEN); + ceph_start_encoding(&p, 2, 1, ARRAY_SIZE(buf) - CEPH_ENCODING_START_BLK_LEN); ceph_encode_32(&p, notify_op); ceph_encode_64(&p, cid.gid); ceph_encode_64(&p, cid.handle); return ceph_osdc_notify(osdc, &rbd_dev->header_oid, - &rbd_dev->header_oloc, buf, buf_size, + &rbd_dev->header_oloc, buf, ARRAY_SIZE(buf), RBD_NOTIFY_TIMEOUT, preply_pages, preply_len); } -- 2.7.4
Re: [PATCH] mmc: card: Don't show eMMC RPMB and BOOT areas in /proc/partitions
On Saturday 10 March 2018 05:29 PM, Linus Walleij wrote: > > But this patch doesn't hide the partition from userspace does it? > > They will still appear in /dev/mmcblk0boot1 etc. > > Just not reported as "real" partitions in /proc/partitions. > > Or do I misunderstand it? > > You are correct. This patch does not hide partition from userspace. They will still appear in /dev/. But not reported as "real" partitions in /proc/partiotions. Thanks, Harish Jenny K N
Re: [PATCH v4 14/24] fpga: dfl: fme: add partial reconfiguration sub feature support
On Sun, Mar 11, 2018 at 01:09:31PM -0700, matthew.gerl...@linux.intel.com wrote: > > > On Mon, 5 Mar 2018, Alan Tull wrote: > > > Hi Hao, > > I do think we should consider different hw implementations with this code > because it does look like most of it is generic. Specifically, I think > we should consider DFH based fpga images that have been shipped already, > and I think we need to consider new hardware implementations as well. > Full disclosure, I am particularly interested in porting to a new hw > implementation for partial reconfiguration. Hi Matthew, This dfl-fme-pr.c driver is developed for the PR sub feature (feature id = 0x5), but we can reuse it for any cases if possible. > > Please see some comments below. Thanks for the comments, please see my comments inline. > > Matthew Gerlach > > >On Tue, Feb 13, 2018 at 3:24 AM, Wu Hao wrote: > > > >Hi Hao, > > > >We are going to want to be able use different FPGA managers with this > >framework. The different manager may be part of a different FME in > >fabric or it may be a hardware FPGA manager. Fortunately, at this > >point now the changes, noted below, to get there are pretty small. > > > >>From: Kang Luwei > >> > >>Partial Reconfiguration (PR) is the most important function for FME. It > >>allows reconfiguration for given Port/Accelerated Function Unit (AFU). > >> > >>It creates platform devices for fpga-mgr, fpga-regions and fpga-bridges, > >>and invokes fpga-region's interface (fpga_region_program_fpga) for PR > >>operation once PR request received via ioctl. Below user space interface > >>is exposed by this sub feature. > >> > >>Ioctl interface: > >>* FPGA_FME_PORT_PR > >> Do partial reconfiguration per information from userspace, including > >> target port(AFU), buffer size and address info. It returns error code > >> to userspace if failed. For detailed PR error information, user needs > >> to read fpga-mgr's status sysfs interface. > >> > >>Signed-off-by: Tim Whisonant > >>Signed-off-by: Enno Luebbers > >>Signed-off-by: Shiva Rao > >>Signed-off-by: Christopher Rauer > >>Signed-off-by: Kang Luwei > >>Signed-off-by: Xiao Guangrong > >>Signed-off-by: Wu Hao > >>--- > >>v2: moved the code to drivers/fpga folder as suggested by Alan Tull. > >>switched to GPLv2 license. > >>removed status from FPGA_FME_PORT_PR ioctl data structure. > >>added platform devices creation for fpga-mgr/fpga-region/fpga-bridge. > >>switched to fpga-region interface fpga_region_program_fpga for PR. > >>fixed comments from Alan Tull on FPGA_MGR_PARTIAL_RECONFIG flag usage. > >>fixed kbuild warnings. > >>v3: rename driver files to dfl-fme-*. > >>rebase due to fpga APIs change. > >>replace bitfields. > >>switch to fpga_cdev_find_port to find port device. > >>v4: rebase and correct comments for some function. > >>fix SPDX license issue. > >>remove unnecessary input parameter for destroy_bridge/region function. > >>add dfl-fme-pr.h for PR sub feature data structure and registers. > >>--- > >> drivers/fpga/Makefile | 2 +- > >> drivers/fpga/dfl-fme-main.c | 45 +++- > >> drivers/fpga/dfl-fme-pr.c | 497 > >> ++ > >> drivers/fpga/dfl-fme-pr.h | 113 ++ > >> drivers/fpga/dfl-fme.h| 38 > >> include/uapi/linux/fpga-dfl.h | 27 +++ > >> 6 files changed, 720 insertions(+), 2 deletions(-) > >> create mode 100644 drivers/fpga/dfl-fme-pr.c > >> create mode 100644 drivers/fpga/dfl-fme-pr.h > >> create mode 100644 drivers/fpga/dfl-fme.h > >> > >>diff --git a/drivers/fpga/Makefile b/drivers/fpga/Makefile > >>index fbd1c85..3c44fc9 100644 > >>--- a/drivers/fpga/Makefile > >>+++ b/drivers/fpga/Makefile > >>@@ -32,7 +32,7 @@ obj-$(CONFIG_OF_FPGA_REGION) += of-fpga-region.o > >> obj-$(CONFIG_FPGA_DFL) += dfl.o > >> obj-$(CONFIG_FPGA_DFL_FME) += dfl-fme.o > >> > >>-dfl-fme-objs := dfl-fme-main.o > >>+dfl-fme-objs := dfl-fme-main.o dfl-fme-pr.o > >> > >> # Drivers for FPGAs which implement DFL > >> obj-$(CONFIG_FPGA_DFL_PCI) += dfl-pci.o > >>diff --git a/drivers/fpga/dfl-fme-main.c b/drivers/fpga/dfl-fme-main.c > >>index 1a9929c..967a44c 100644 > >>--- a/drivers/fpga/dfl-fme-main.c > >>+++ b/drivers/fpga/dfl-fme-main.c > >>@@ -19,6 +19,7 @@ > >> #include > >> > >> #include "dfl.h" > >>+#include "dfl-fme.h" > >> > >> static ssize_t ports_num_show(struct device *dev, > >> struct device_attribute *attr, char *buf) > >>@@ -111,6 +112,10 @@ static struct feature_driver fme_feature_drvs[] = { > >>.ops = &fme_hdr_ops, > >>}, > >>{ > >>+ .id = FME_FEATURE_ID_PR_MGMT, > >>+ .ops = &pr_mgmt_ops, > >>+ }, > >>+ { > >>.ops = NULL, > >>}, > >> }; > >>@@ -194,14 +199,49 @@ static const struct file_operations fme_fops = { > >>.unlocked_ioctl = fme_ioctl, > >> }; > >> > >>+stati
Re: [PATCH 10/10] dt-bindings: thermal: Remove "cooling-{min|max}-level" properties
On 09-02-18, 14:28, Viresh Kumar wrote: > The "cooling-min-level" and "cooling-max-level" properties are not > parsed by any part of kernel currently and the max cooling state of a > CPU cooling device is found by referring to the cpufreq table instead. > > Remove the unused bindings. > > Signed-off-by: Viresh Kumar > --- > Documentation/devicetree/bindings/thermal/thermal.txt | 16 +--- > 1 file changed, 1 insertion(+), 15 deletions(-) @Zhang/Eduardo: Can you please pick this patch (10/10) as almost everything else is already lined up for 4.17 ? -- viresh
Re: [PATCH 07/10] ARM: dts: gemini: Remove "cooling-{min|max}-level" for gpio-fan node
On 09-02-18, 14:28, Viresh Kumar wrote: > The "cooling-min-level" and "cooling-max-level" properties are not > parsed by any part of the kernel currently and the max cooling state of > gpio-fan cooling device is found by referring to the > "gpio-fan,speed-map" instead. > > Remove the unused properties from the gpio-fan node. > > Signed-off-by: Viresh Kumar > --- > arch/arm/boot/dts/gemini-dlink-dns-313.dts | 2 -- > 1 file changed, 2 deletions(-) > > diff --git a/arch/arm/boot/dts/gemini-dlink-dns-313.dts > b/arch/arm/boot/dts/gemini-dlink-dns-313.dts > index 08568ce24d06..727d16eb02d9 100644 > --- a/arch/arm/boot/dts/gemini-dlink-dns-313.dts > +++ b/arch/arm/boot/dts/gemini-dlink-dns-313.dts > @@ -78,8 +78,6 @@ > gpios = <&gpio0 11 GPIO_ACTIVE_HIGH>, > <&gpio0 12 GPIO_ACTIVE_HIGH>; > gpio-fan,speed-map = <0 0>, <3000 1>, <6000 2>; > - cooling-min-level = <0>; > - cooling-max-level = <2>; > #cooling-cells = <2>; > }; > @Linus: Can you please pick this one for 4.17 ? -- viresh
RE: [PATCH v7] staging: typec: handle vendor defined part and modify drp toggling flow
Hi, > +static irqreturn_t _tcpci_irq(int irq, void *dev_id) { > + struct tcpci *tcpci = dev_id; > + > + return tcpci_irq(tcpci); > +} > ... > + err = devm_request_threaded_irq(&client->dev, client->irq, NULL, > + _tcpci_irq, > IRQF_ONESHOT | IRQF_TRIGGER_LOW, > - dev_name(tcpci->dev), tcpci); > + dev_name(&client->dev), chip); - dev_name(&client->dev), chip); + dev_name(&client->dev), chip->tcpci); Did you ever test this patch? I noticed Greg already picked this patch[1]: [1] https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git/commit/?h=usb-testing&id=8f94390226487bcb86c554ddc12eef0d27bdec3b One more minor comment below. Jun Li > diff --git a/drivers/staging/typec/tcpci.h b/drivers/staging/typec/tcpci.h > index > fdfb06c..a2c1754 100644 > --- a/drivers/staging/typec/tcpci.h > +++ b/drivers/staging/typec/tcpci.h > @@ -59,6 +59,7 @@ > #define TCPC_POWER_CTRL_VCONN_ENABLE BIT(0) > > #define TCPC_CC_STATUS 0x1d > +#define TCPC_CC_STATUS_DRPRSTBIT(5) Defined but not used. > #define TCPC_CC_STATUS_TERM BIT(4) > #define TCPC_CC_STATUS_CC2_SHIFT 2 > #define TCPC_CC_STATUS_CC2_MASK 0x3 > @@ -121,4 +122,18 @@ > #define TCPC_VBUS_VOLTAGE_ALARM_HI_CFG 0x76 > #define TCPC_VBUS_VOLTAGE_ALARM_LO_CFG 0x78 > > +struct tcpci; > +struct tcpci_data { > + struct regmap *regmap; > + int (*init)(struct tcpci *tcpci, struct tcpci_data *data); > + int (*set_vconn)(struct tcpci *tcpci, struct tcpci_data *data, > + bool enable); > + int (*start_drp_toggling)(struct tcpci *tcpci, struct tcpci_data *data, > + enum typec_cc_status cc); > +}; > + > +struct tcpci *tcpci_register_port(struct device *dev, struct tcpci_data > +*data); void tcpci_unregister_port(struct tcpci *tcpci); irqreturn_t > +tcpci_irq(struct tcpci *tcpci); > + > #endif /* __LINUX_USB_TCPCI_H */ > -- > 1.9.1
Re: [PATCH 06/10] ARM64: dts: meson: Remove "cooling-{min|max}-level" for CPU nodes
On 09-02-18, 10:03, Neil Armstrong wrote: > On 09/02/2018 09:58, Viresh Kumar wrote: > > The "cooling-min-level" and "cooling-max-level" properties are not > > parsed by any part of the kernel currently and the max cooling state of > > a CPU cooling device is found by referring to the cpufreq table instead. > > > > Remove the unused properties from the CPU nodes. > > > > Signed-off-by: Viresh Kumar > > --- > > arch/arm64/boot/dts/amlogic/meson-gxm-khadas-vim2.dts | 4 > > 1 file changed, 4 deletions(-) > > > > diff --git a/arch/arm64/boot/dts/amlogic/meson-gxm-khadas-vim2.dts > > b/arch/arm64/boot/dts/amlogic/meson-gxm-khadas-vim2.dts > > index 1448c3dba08e..658215c9822c 100644 > > --- a/arch/arm64/boot/dts/amlogic/meson-gxm-khadas-vim2.dts > > +++ b/arch/arm64/boot/dts/amlogic/meson-gxm-khadas-vim2.dts > > @@ -209,14 +209,10 @@ > > }; > > > > &cpu0 { > > - cooling-min-level = <0>; > > - cooling-max-level = <6>; > > #cooling-cells = <2>; > > }; > > > > &cpu4 { > > - cooling-min-level = <0>; > > - cooling-max-level = <4>; > > #cooling-cells = <2>; > > }; > > > > > > Acked-by: Neil Armstrong Is Kevin going to apply these for 4.17 ? -- viresh
Re: [PATCH V4] thermal: Add cooling device's statistics in sysfs
On 16-01-18, 15:22, Viresh Kumar wrote: > This extends the sysfs interface for thermal cooling devices and exposes > some pretty useful statistics. These statistics have proven to be quite > useful specially while doing benchmarks related to the task scheduler, > where we want to make sure that nothing has disrupted the test, > specially the cooling device which may have put constraints on the CPUs. > The information exposed here tells us to what extent the CPUs were > constrained by the thermal framework. @Eduardo/Zhang: Are you going to merge this for 4.17 ? -- viresh
[PATCH v9] mmc: Export host capabilities to debugfs.
This patch exports the host capabilities to debugfs This idea of sharing host capabilities over debugfs came up from Abbas Raza Earlier discussions: https://lkml.org/lkml/2018/3/5/357 https://www.spinics.net/lists/linux-mmc/msg48219.html Signed-off-by: Harish Jenny K N --- Changes in v9 - More code cleanup as suggested by Andy Shevchenko. Changes in v8 - Changes to use for_each_set_bit as suggested by Andy Shevchenko. Changes in v7 - Moved additional capabilities also to caps file as mentioned by Ulf Hansson - compacting the code with macros Changes in v6: - Used DEFINE_SHOW_ATTRIBUTE Changes in v5: - Added parser logic in kernel by using debugfs_create_file for caps and caps2 instead of debugfs_create_x32 - Changed Author Changes in v4: - Moved the creation of nodes to mmc_add_host_debugfs - Exported caps2 - Renamed host_caps to caps Changes in v3: - Removed typecasting of &host->caps to (u32 *) Changes in v2: - Changed Author drivers/mmc/core/debugfs.c | 107 + 1 file changed, 107 insertions(+) diff --git a/drivers/mmc/core/debugfs.c b/drivers/mmc/core/debugfs.c index c51e0c0..e19305a 100644 --- a/drivers/mmc/core/debugfs.c +++ b/drivers/mmc/core/debugfs.c @@ -225,6 +225,110 @@ static int mmc_clock_opt_set(void *data, u64 val) DEFINE_SIMPLE_ATTRIBUTE(mmc_clock_fops, mmc_clock_opt_get, mmc_clock_opt_set, "%llu\n"); +/* + * mmc_host_capabilities - MMC host capabilities + * + * This must be in sync with caps definitions in the mmc/host.h + */ +static const char * const mmc_host_capabilities[] = { + "4-bit transfers allowed", + "Supports MMC high-speed timing", + "Supports SD high-speed timing", + "Can signal pending SDIO IRQs", + "Talks only SPI protocols", + "Needs polling for card-detection", + "8 bit transfers allowed", + "Suspends (e)MMC/SD at idle", + "Nonremovable", + "Waits while card is busy", + "Allows erase/trim commands", + "Supports DDR mode at 3.3V", + "Supports DDR mode at 1.8V", + "Supports DDR mode at 1.2V", + "Can power off after boot", + "CMD14/CMD19 bus width ok", + "Supports UHS SDR12 mode", + "Supports UHS SDR25 mode", + "Supports UHS SDR50 mode", + "Supports UHS SDR104 mode", + "Supports UHS DDR50 mode", + "Unknown (bit 21)", + "Unknown (bit 22)", + "Supports Driver Type A", + "Supports Driver Type C", + "Supports Driver Type D", + "Unknown (bit 26)", + "RW reqs can be completed within mmc_request_done()", + "Supports Enable card detect wake", + "Can send commands during data transfer", + "CMD23 supported", + "Supports Hardware reset" +}; + +/* + * mmc_host_capabilities2 - MMC host additional capabilities + * + * This must be in sync with caps2 definitions in the mmc/host.h + */ +static const char * const mmc_host_capabilities2[] = { + "No access to Boot partition", + "Unknown (bit 1)", + "Can do full power cycle", + "Unknown (bit 3)", + "Unknown (bit 4)", + "Supports HS200 1.8V SDR", + "Supports HS200 1.2V SDR", + "Unknown (bit 7)", + "Unknown (bit 8)", + "Unknown (bit 9)", + "Card-detect signal active high", + "Write-protect signal active high", + "Unknown (bit 12)", + "Unknown (bit 13)", + "Can do complete power cycle of the card", + "Supports HS400 1.8V", + "Support HS400 1.2V", + "SDIO IRQ - Nothread", + "No physical write protect pin, assume always read-write", + "Do not send SDIO commands during initialization", + "Supports enhanced strobe", + "Do not send SD commands during initialization", + "Do not send (e)MMC commands during initialization", + "Has eMMC command queue engine", + "CQE can issue a direct command", + "Unknown (bit 25)", + "Unknown (bit 26)", + "Unknown (bit 27)", + "Unknown (bit 28)", + "Unknown (bit 29)", + "Unknown (bit 30)", + "Unknown (bit 31)" +}; + +static int mmc_caps_show(struct seq_file *s, void *unused) +{ + struct mmc_host *host = s->private; + unsigned long caps = host->caps; + unsigned long caps2 = host->caps2; + int bit; + + seq_puts(s, "MMC Host capabilities are:\n"); + seq_puts(s, "=\n"); + + for_each_set_bit(bit, (const unsigned long *)&caps, BITS_PER_LONG) + seq_printf(s, "%s\n", mmc_host_capabilities[bit]); + + seq_puts(s, "=\n"); + seq_puts(s, "MMC Host additional capabilities are:\n"); + seq_puts(s, "=\n"); + + for_each_set_bit(bit, (const unsigned long *)&caps2, BITS_PER_LONG) + seq_printf(s, "%s\n", mmc_host_capabilities2[bit]); + + return 0; +} +DEFINE_SHOW_ATTRIBU
[PATCH] of: unittest: Remove VLA stack usage
The kernel would like to have all stack VLA usage removed[1]. This is a test function so the execution speed is not critical. We can allocate memory for this buffer instead of using a VLA. If kmalloc() fails just return. Allocate buffer with kmalloc(). [1]: https://lkml.org/lkml/2018/3/7/621 Signed-off-by: Tobin C. Harding --- Kees is this annoying you, CC'ing you an all my VLA patches? drivers/of/unittest.c | 15 +++ 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c index 1991fe4319f5..38cbc343b7da 100644 --- a/drivers/of/unittest.c +++ b/drivers/of/unittest.c @@ -254,12 +254,18 @@ static void __init of_unittest_check_tree_linkage(void) static void __init of_unittest_printf_one(struct device_node *np, const char *fmt, const char *expected) { - unsigned char buf[strlen(expected)+10]; + unsigned char *buf; + int buf_size; int size, i; + buf_size = strlen(expected) + 10; + buf = kmalloc(buf_size, GFP_KERNEL); + if (!buf) + return; + /* Baseline; check conversion with a large size limit */ - memset(buf, 0xff, sizeof(buf)); - size = snprintf(buf, sizeof(buf) - 2, fmt, np); + memset(buf, 0xff, buf_size); + size = snprintf(buf, buf_size - 2, fmt, np); /* use strcmp() instead of strncmp() here to be absolutely sure strings match */ unittest((strcmp(buf, expected) == 0) && (buf[size+1] == 0xff), @@ -270,12 +276,13 @@ static void __init of_unittest_printf_one(struct device_node *np, const char *fm size++; for (i = 0; i < 2; i++, size--) { /* Clear the buffer, and make sure it works correctly still */ - memset(buf, 0xff, sizeof(buf)); + memset(buf, 0xff, buf_size); snprintf(buf, size+1, fmt, np); unittest(strncmp(buf, expected, size) == 0 && (buf[size+1] == 0xff), "snprintf failed; size=%i fmt='%s' expected='%s' rslt='%s'\n", size, fmt, expected, buf); } + kfree(buf); } static void __init of_unittest_printf(void) -- 2.7.4
[PATCH 3/4] ARM: dts: sun8i: a33: Enable PMIC power supplies on A33-OLinuXino
The A33-OLinuXino has a DC jack wired to the onboard PMIC's ACIN pins. There is also a battery connector, wired to the PMIC's battery charger. Enable the power supplies for both these components. Signed-off-by: Chen-Yu Tsai --- arch/arm/boot/dts/sun8i-a33-olinuxino.dts | 8 1 file changed, 8 insertions(+) diff --git a/arch/arm/boot/dts/sun8i-a33-olinuxino.dts b/arch/arm/boot/dts/sun8i-a33-olinuxino.dts index 925a5339711f..7f8a481af570 100644 --- a/arch/arm/boot/dts/sun8i-a33-olinuxino.dts +++ b/arch/arm/boot/dts/sun8i-a33-olinuxino.dts @@ -101,6 +101,14 @@ #include "axp223.dtsi" +&ac_power_supply { + status = "okay"; +}; + +&battery_power_supply { + status = "okay"; +}; + ®_aldo1 { regulator-always-on; regulator-min-microvolt = <330>; -- 2.16.2
[PATCH 2/4] ARM: dts: sun8i: a33: Drop sunxi-common-regulators.dtsi for A33-OLinuXino
None of the common regulators defined in sunxi-common-regulators.dtsi are used for the A33-OLinuXino. Drop the include. Signed-off-by: Chen-Yu Tsai --- arch/arm/boot/dts/sun8i-a33-olinuxino.dts | 1 - 1 file changed, 1 deletion(-) diff --git a/arch/arm/boot/dts/sun8i-a33-olinuxino.dts b/arch/arm/boot/dts/sun8i-a33-olinuxino.dts index 6349e0bec9a3..925a5339711f 100644 --- a/arch/arm/boot/dts/sun8i-a33-olinuxino.dts +++ b/arch/arm/boot/dts/sun8i-a33-olinuxino.dts @@ -43,7 +43,6 @@ /dts-v1/; #include "sun8i-a33.dtsi" -#include "sunxi-common-regulators.dtsi" #include #include -- 2.16.2
[PATCH 0/4] ARM: dts: sun8i: a33: Improvements for A33-OLinuXino
Hi, Here are some cleanup and improvements for the A33-OLinuXino device tree. The first two patches drop some unneeded bits. The latter two enable peripherals that we now support. ChenYu Chen-Yu Tsai (4): ARM: dts: sun8i: a33: Drop GPIO pinmux settings for A33-OLinuXino ARM: dts: sun8i: a33: Drop sunxi-common-regulators.dtsi for A33-OLinuXino ARM: dts: sun8i: a33: Enable PMIC power supplies on A33-OLinuXino ARM: dts: sun8i: a33: Enable A33 internal audio codec on A33-OLinuXino arch/arm/boot/dts/sun8i-a33-olinuxino.dts | 55 ++- 1 file changed, 32 insertions(+), 23 deletions(-) -- 2.16.2
[PATCH 1/4] ARM: dts: sun8i: a33: Drop GPIO pinmux settings for A33-OLinuXino
Normal GPIO usage does not need an additional pinmix setting. Exclusive usage of the pin will be guaranteed by the driver. Drop the extra pinmux settings. Signed-off-by: Chen-Yu Tsai --- arch/arm/boot/dts/sun8i-a33-olinuxino.dts | 23 +-- 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/arch/arm/boot/dts/sun8i-a33-olinuxino.dts b/arch/arm/boot/dts/sun8i-a33-olinuxino.dts index 9757265c58d4..6349e0bec9a3 100644 --- a/arch/arm/boot/dts/sun8i-a33-olinuxino.dts +++ b/arch/arm/boot/dts/sun8i-a33-olinuxino.dts @@ -62,8 +62,6 @@ leds { compatible = "gpio-leds"; - pinctrl-names = "default"; - pinctrl-0 = <&led_pin_olinuxino>; green { label = "a33-olinuxino:green:usr"; @@ -78,7 +76,7 @@ &mmc0 { pinctrl-names = "default"; - pinctrl-0 = <&mmc0_pins_a>, <&mmc0_cd_pin_olinuxino>; + pinctrl-0 = <&mmc0_pins_a>; vmmc-supply = <®_dcdc1>; bus-width = <4>; cd-gpios = <&pio 1 4 GPIO_ACTIVE_LOW>; /* PB4 */ @@ -89,23 +87,6 @@ status = "okay"; }; -&pio { - led_pin_olinuxino: led_pins@0 { - pins = "PB7"; - function = "gpio_out"; - }; - - mmc0_cd_pin_olinuxino: mmc0_cd_pin@0 { - pins = "PB4"; - function = "gpio_in"; - }; - - usb0_id_detect_pin: usb0_id_detect_pin@0 { - pins = "PB3"; - function = "gpio_in"; - }; -}; - &r_rsb { status = "okay"; @@ -210,8 +191,6 @@ }; &usbphy { - pinctrl-names = "default"; - pinctrl-0 = <&usb0_id_detect_pin>; usb0_id_det-gpios = <&pio 1 3 GPIO_ACTIVE_HIGH>; /* PB3 */ usb0_vbus_power-supply = <&usb_power_supply>; usb0_vbus-supply = <®_drivevbus>; -- 2.16.2
[PATCH 4/4] ARM: dts: sun8i: a33: Enable A33 internal audio codec on A33-OLinuXino
The A33-OLinuXino routes the SoC's headphone output to a headphone jack, and the microphone input to a microphone jack. Power to the microphone is provided by MBIAS. This patch enables the various parts of the codec, and adds widgets and routes for simple-card. HBIAS is connected to the microphone jack as well, but in a manner that is confusing and likely does not provide power. This part is left out of this patch. Signed-off-by: Chen-Yu Tsai --- arch/arm/boot/dts/sun8i-a33-olinuxino.dts | 23 +++ 1 file changed, 23 insertions(+) diff --git a/arch/arm/boot/dts/sun8i-a33-olinuxino.dts b/arch/arm/boot/dts/sun8i-a33-olinuxino.dts index 7f8a481af570..a1a1eb64caeb 100644 --- a/arch/arm/boot/dts/sun8i-a33-olinuxino.dts +++ b/arch/arm/boot/dts/sun8i-a33-olinuxino.dts @@ -69,6 +69,14 @@ }; }; +&codec { + status = "okay"; +}; + +&dai { + status = "okay"; +}; + &ehci0 { status = "okay"; }; @@ -182,6 +190,21 @@ vcc-lcd-supply = <®_dc1sw>; }; +&sound { + /* Board level jack widgets */ + simple-audio-card,widgets = "Microphone", "Microphone Jack", + "Headphone", "Headphone Jack"; + /* Board level routing. First 2 routes copied from SoC level */ + simple-audio-card,routing = + "Left DAC", "AIF1 Slot 0 Left", + "Right DAC", "AIF1 Slot 0 Right", + "HP", "HPCOM", + "Headphone Jack", "HP", + "MIC1", "Microphone Jack", + "Microphone Jack", "MBIAS"; + status = "okay"; +}; + &uart0 { pinctrl-names = "default"; pinctrl-0 = <&uart0_pins_b>; -- 2.16.2
[PATCH] ARM: dts: sun8i: reference tablet design: Enable PMIC power supplies
The A23/A33 reference tablet design has a DC barrel tied to the ACIN of the PMIC. And being a tablet, it has a Li-Po battery. Enable both power supplies in the device tree. Signed-off-by: Chen-Yu Tsai --- arch/arm/boot/dts/sun8i-reference-design-tablet.dtsi | 8 1 file changed, 8 insertions(+) diff --git a/arch/arm/boot/dts/sun8i-reference-design-tablet.dtsi b/arch/arm/boot/dts/sun8i-reference-design-tablet.dtsi index f51f37cc721d..880096c7e252 100644 --- a/arch/arm/boot/dts/sun8i-reference-design-tablet.dtsi +++ b/arch/arm/boot/dts/sun8i-reference-design-tablet.dtsi @@ -124,6 +124,14 @@ #include "axp223.dtsi" +&ac_power_supply { + status = "okay"; +}; + +&battery_power_supply { + status = "okay"; +}; + ®_aldo1 { regulator-always-on; regulator-min-microvolt = <300>; -- 2.16.2
Re: ivtv: use arch_phys_wc_add() and require PAT disabled
On Sun, Mar 11, 2018 at 11:24:38PM +, Ian Armstrong wrote: > On Sat, 10 Mar 2018 16:57:41 + > "French, Nicholas A." wrote: > > > > > No what if the framebuffer driver is just requested as a > > > > secondary step after firmware loading? > > > > > > Its a possibility. The decoder firmware gets loaded at the > > > beginning of the decoder memory range and we know its length, so > > > its possible to ioremap_nocache enough room for the firmware only > > > on init and then ioremap the remaining non-firmware decoder memory > > > areas appropriately after the firmware load succeeds... > > > > I looked in more detail, and this would be "hard" due to the way the > > rest of the decoder offsets are determined by either making firmware > > calls or scanning the decoder memory range for magic bytes and other > > mess. > > The buffers used for yuv output are fixed. They are located both before > and after the framebuffer. Their offset is fixed at 'base_addr + > IVTV_DECODER_OFFSET + yuv_offset[]'. The yuv offsets can be found in > 'ivtv-yuv.c'. The buffers are 622080 bytes in length. > > The range would be from 'base_addr + 0x0100 + 0x00029000' to > 'base_addr + 0x0100 + 0x00748200 + 0x97dff'. This is larger than > required, but will catch the framebuffer and should not cause any > problems. If you wanted to render direct to the yuv buffers, you would > probably want this region included anyway (not that the current driver > supports that). Am I correct that you are talking about the possibility of re-ioremap()-ing the 'yuv-fb-yuv' area *after* loading the firmware, not of mapping ranges correctly on the first go-around? Because unless my math is letting me down, the decoder firmware is already loaded from 'base_addr + 0x0100 + 0x0' to 'base_addr + 0x0100 + 0x3' which overlaps the beginning of the yuv range. - Nick
Re: [pci PATCH v4 1/4] pci-iov: Add support for unmanaged SR-IOV
On Thu, 08 Mar 2018 11:02:29 -0800 Alexander Duyck wrote: > From: Alexander Duyck > > This patch is meant to add some basic functionality to support for SR-IOV > on devices when the VFs are not managed by some other entity in the device > other than the kernel. > > A new sysfs value called sriov_unmanaged_autoprobe has been added. This > value is used as the drivers_autoprobe setting of the VFs when they are > being managed by an external entity such as device firmware instead of > being managed by the kernel. > > One side effect of this change is that the sriov_drivers_autoprobe and > sriov_unmanaged_autoprobe will only apply their updates when SR-IOV VFs > are allocated. Attempts to update them when SR-IOV is in use will only > update the local value and will not update sriov->autoprobe. > > Signed-off-by: Alexander Duyck > --- I still struggle to understand why we need this "unmanaged" complication and how a user of the sysfs API is expected to have any idea whether a PF is managed or unmanaged and why they should care. Can't we just have a pci_simple_sriov_configure() helper and ignore this unmanaged business? Thanks, Alex
Re: [RFC PATCH v2 00/12] Rewrite asm-generic/bitops/{atomic,lock}.h and use on arm64
Hi Will, 2018-03-01 16:16 GMT+09:00 Masahiro Yamada : > 2018-02-27 0:04 GMT+09:00 Will Deacon : >> Hi everyone, >> >> This is version two of the RFC I previously posted here: >> >> https://www.spinics.net/lists/arm-kernel/msg634719.html >> >> Changes since v1 include: >> >> * Fixed __clear_bit_unlock to work on archs with lock-based atomics >> * Moved lock ops into bitops/lock.h >> * Fixed build breakage on lesser-spotted architectures >> >> Trying to fix the circular #includes introduced by pulling atomic.h >> into btops/lock.h has been driving me insane. I've ended up moving some >> basic BIT definitions into bits.h, but this might all be better in >> const.h which is being proposed by Masahiro. Feedback is especially >> welcome on this part. > > > Info for reviewers: > > You can see my patches at the following: > > 1/5: https://patchwork.kernel.org/patch/10235457/ > 2/5: https://patchwork.kernel.org/patch/10235461/ > 3/5: https://patchwork.kernel.org/patch/10235463/ > 4/5: https://patchwork.kernel.org/patch/10235469/ > 5/5: https://patchwork.kernel.org/patch/10235471/ > > > 5/5 has conflict with Will's 2/12. > > Fortunately, it is at the tail of the series. > It is easy to pick/drop/change > when we decide how to organize it. No comments so far about this part. I think your approach is better since putting BIT* macros into a single header is more consistent. So, I will ask Andrew to drop mine. However, I think will make more sense than These macros are really arch-agnostic. So, we would not expect to have that could fall back to , right? -- Best Regards Masahiro Yamada
[PATCH 3.2 000/104] 3.2.101-rc1 review
This is the start of the stable review cycle for the 3.2.101 release. There are 104 patches in this series, which will be posted as responses to this one. If anyone has any issues with these being applied, please let me know. Responses should be made by Wed Mar 14 12:00:00 UTC 2018. Anything received after that time might be too late. All the patches have also been committed to the linux-3.2.y-rc branch of https://git.kernel.org/pub/scm/linux/kernel/git/bwh/linux-stable-rc.git . A shortlog and diffstat can be found below. Ben. - Alexandre Oliva (1): brcmfmac: work-around gcc 4.7 build issue [5addc0de28f5e286f9d121112c450807b5a5] Andi Kleen (5): ath6kl: fix uninitialized variable in ath6kl_sdio_enable_scatter() [527f6570300980251e818e80865b437eefb4e5d3] brcm80211: Remove bogus memcpy in ai_detach [af2c8ffe56133928355d1d51978b35115ffbbc2a] module/retpoline: Warn about missing retpoline in module [caf7501a1b4ec964190f31f9c3f163de252273b8] x86/retpoline/irq32: Convert assembler indirect jumps [7614e913db1f40fff819b36216484dc3808995d4] x86/retpoline: Optimize inline assembler for vmexit_fill_RSB [3f7d875566d8e79c5e0b2c9a413e91b2c29e0854] Andrey Ryabinin (1): x86/asm: Use register variable to get stack pointer value [196bd485ee4f03ce4c690bfcf38138abfcd0a4bc] Andy Lutomirski (2): x86/asm: Make asm/alternative.h safe from assembly [f005f5d860e0231fe212cfda8c1a3148b99609f4] x86/cpu: Factor out application of forced CPU caps [8bf1ebca215c262e48c15a4a15f175991776f57f] Arnd Bergmann (2): Turn off -Wmaybe-uninitialized when building with -Os [e74fc973b6e531fef1fce8b10105ecfb774c] x86: fix build warnign with 32-bit PAE [not upstream; specific to KAISER] Avi Kivity (2): KVM: SVM: Make use of asm.h [7454766f7bead388251aedee35a478356a7f4e72] KVM: VMX: Make use of asm.h [b188c81f2e1a188ddda6a3d353e5b546c30a9b90] Ben Hutchings (1): x86/syscall: Sanitize syscall table de-references under speculation [2fbd7af5af8665d18bcefae3e9700be07e22b681] Borislav Petkov (9): x86, cpu: Expand cpufeature facility to include cpu bugs [65fc985b37dc241c4db7cd32adcbc989193fe3c8] x86/alternatives: Fix ALTERNATIVE_2 padding generation properly [dbe4058a6a44af4ca5d146aebe01b0a1f9b7fd2a] x86/alternatives: Fix optimize_nops() checking [612e8e9350fd19cae6900cf36ea0c6892d1a0dca] x86/alternatives: Guard NOPs optimization [69df353ff305805fc16082d0c5bfa6e20fa8b863] x86/bitops: Move BIT_64() for a wider use [e8f380e00840f694599e6ab42806639f7de26f11] x86/bugs: Drop one "mitigation" from dmesg [55fa19d3e51f33d9cd4056d25836d93abf9438db] x86/cpu: Merge bugs.c and bugs_64.c [62a67e123e058a67db58bc6a14354dd037bafd0a] x86/nospec: Fix header guards names [7a32fc51ca938e67974cbb9db31e1a43f98345a9] x86: Add another set of MSR accessor functions [22085a66c2fab6cf9b9393c056a3600a6b4735de] Colin Ian King (1): x86/spectre: Fix spelling mistake: "vunerable"-> "vulnerable" [e698dcdfcda41efd0984de539767b4cddd235f1e] Dan Carpenter (1): x86/spectre: Fix an error message [9de29eac8d2189424d81c0d840cd0469aa3d41c8] Dan Williams (11): array_index_nospec: Sanitize speculative array de-references [f3804203306e098dae9ca51540fcd5eb700d7f40] nospec: Include dependency [eb6174f6d1be16b19cfa43dac296bfed003ce1a6] nospec: Kill array_index_nospec_mask_check() [1d91c1d2c80cb70e2e553845e278b87a960c04da] vfs, fdtable: Prevent bounds-check bypass via speculative execution [56c30ba7b348b90484969054d561f711ba196507] x86/get_user: Use pointer masking to limit speculation [c7f631cb07e7da06ac1d231ca178452339e32a94] x86/kvm: Update spectre-v1 mitigation [085331dfc6bbe3501fb936e657331ca943827600] x86/spectre: Report get_user mitigation for spectre_v1 [edfbae53dab8348fca778531be9f4855d2ca0360] x86/uaccess: Use __uaccess_begin_nospec() and uaccess_try_nospec [304ec1b050310548db33063e567123fae8fd0301] x86: Implement array_index_mask_nospec [babdde2698d482b6c0de1eab4f697cf5856c5859] x86: Introduce __uaccess_begin_nospec() and uaccess_try_nospec [b3bbfb3fb5d25776b8e3f361d2eedaabb0b496cd] x86: Introduce barrier_nospec [b3d7ad85b80bbc404635dca80f5b129f6242bc7a] Danny Kukawka (1): [media] max2165: trival fix for some -Wuninitialized warning [32d7e63c1f4f86ad18404e3f36be99c9910fae9b] Darren Kenny (1): x86/speculation: Fix typo IBRS_ATT, which should be IBRS_ALL [af189c95a371b59f493dbe0f50c0a09724868881] Dave Hansen (2): x86/Documentation: Add PTI description [01c9b17bf673b05bb401b76ec763e9730cc
[PATCH 3.2 005/104] ath6kl: fix uninitialized variable in ath6kl_sdio_enable_scatter()
3.2.101-rc1 review patch. If anyone has any objections, please let me know. -- From: Andi Kleen commit 527f6570300980251e818e80865b437eefb4e5d3 upstream. gcc 4.8 warns /backup/lsrc/git/linux-lto-2.6/drivers/net/wireless/ath/ath6kl/sdio.c: In function 'ath6kl_sdio_enable_scatter': /backup/lsrc/git/linux-lto-2.6/drivers/net/wireless/ath/ath6kl/sdio.c:748:16: warning: 'ret' may be used uninitialized in this function [-Wmaybe-uninitialized] if (virt_scat || ret) { ^ The variable can indeed be uninitialized when the previous if branch is skipped. I just set it to zero for now. I'm not fully sure the fix is correct, maybe the || should be an && ? Signed-off-by: Andi Kleen Signed-off-by: Kalle Valo Signed-off-by: Ben Hutchings --- drivers/net/wireless/ath/ath6kl/sdio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/net/wireless/ath/ath6kl/sdio.c +++ b/drivers/net/wireless/ath/ath6kl/sdio.c @@ -670,7 +670,7 @@ static int ath6kl_sdio_enable_scatter(st { struct ath6kl_sdio *ar_sdio = ath6kl_sdio_priv(ar); struct htc_target *target = ar->htc_target; - int ret; + int ret = 0; bool virt_scat = false; /* check if host supports scatter and it meets our requirements */
[PATCH 3.2 004/104] brcm80211: Remove bogus memcpy in ai_detach
3.2.101-rc1 review patch. If anyone has any objections, please let me know. -- From: Andi Kleen commit af2c8ffe56133928355d1d51978b35115ffbbc2a upstream. gcc 4.8 warns for this memcpy. While the copy size is correct, the whole copy seems to be a nop because the destination is never used, and there's no need to use memcpy to copy pointers anyways. And the type of the pointer was wrong, but at least those are always the same. Just remove it. /backup/lsrc/git/linux-lto-2.6/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c: In function 'ai_detach': /backup/lsrc/git/linux-lto-2.6/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c:539:32: warning: argument to 'sizeof' in 'memcpy' call is the same pointer type 'struct si_pub **' as the destination; expected 'struct si_pub *' or an explicit length [-Wsizeof-pointer-memaccess] memcpy(&si_local, &sih, sizeof(struct si_pub **)); ^ Signed-off-by: Andi Kleen Signed-off-by: John W. Linville [bwh: Backported to 3.2: adjust context] Signed-off-by: Ben Hutchings --- drivers/net/wireless/brcm80211/brcmsmac/aiutils.c | 3 --- 1 file changed, 3 deletions(-) --- a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c @@ -1193,9 +1193,6 @@ void ai_detach(struct si_pub *sih) { struct si_info *sii; - struct si_pub *si_local = NULL; - memcpy(&si_local, &sih, sizeof(struct si_pub **)); - sii = (struct si_info *)sih; if (sii == NULL)
[PATCH 3.2 009/104] rtl8192c:dm: Properly initialize local array and set value.
3.2.101-rc1 review patch. If anyone has any objections, please let me know. -- From: Han Shen commit 7c8f0db0d024efda38976fc2acf7743f458e1d96 upstream. GCC 4.8 is spitting out uninitialized-variable warnings against "drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c". This patch adds initialization to the variable and properly sets its value. Signed-off-by: Han Shen (shen...@google.com) Acked-by: Larry Finger Signed-off-by: John W. Linville Signed-off-by: Ben Hutchings --- drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c +++ b/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c @@ -672,7 +672,7 @@ static void rtl92c_dm_txpower_tracking_c u8 thermalvalue, delta, delta_lck, delta_iqk; long ele_a, ele_d, temp_cck, val_x, value32; long val_y, ele_c = 0; - u8 ofdm_index[2], ofdm_index_old[2], cck_index_old = 0; + u8 ofdm_index[2], ofdm_index_old[2] = {0, 0}, cck_index_old = 0; s8 cck_index = 0; int i; bool is2t = IS_92C_SERIAL(rtlhal->version); @@ -722,7 +722,7 @@ static void rtl92c_dm_txpower_tracking_c for (i = 0; i < OFDM_TABLE_LENGTH; i++) { if (ele_d == (ofdmswing_table[i] & MASKOFDM_D)) { - + ofdm_index_old[1] = (u8) i; RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD, ("Initial pathB ele_d reg0x%x = "
[PATCH 3.2 103/104] x86: fix build warnign with 32-bit PAE
3.2.101-rc1 review patch. If anyone has any objections, please let me know. -- From: Arnd Bergmann I ran into a 4.9 build warning in randconfig testing, starting with the KAISER patches: arch/x86/kernel/ldt.c: In function 'alloc_ldt_struct': arch/x86/include/asm/pgtable_types.h:208:24: error: large integer implicitly truncated to unsigned type [-Werror=overflow] #define __PAGE_KERNEL (__PAGE_KERNEL_EXEC | _PAGE_NX) ^ arch/x86/kernel/ldt.c:81:6: note: in expansion of macro '__PAGE_KERNEL' __PAGE_KERNEL); ^ I originally ran into this last year when the patches were part of linux-next, and tried to work around it by using the proper 'pteval_t' types consistently, but that caused additional problems. This takes a much simpler approach, and makes the argument type of the dummy helper always 64-bit, which is wide enough for any page table layout and won't hurt since this call is just an empty stub anyway. Fixes: 8f0baadf2bea ("kaiser: merged update") Signed-off-by: Arnd Bergmann Acked-by: Kees Cook Acked-by: Hugh Dickins Signed-off-by: Greg Kroah-Hartman Signed-off-by: Ben Hutchings --- include/linux/kaiser.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/kaiser.h b/include/linux/kaiser.h index 58c55b1589d0..b56c19010480 100644 --- a/include/linux/kaiser.h +++ b/include/linux/kaiser.h @@ -32,7 +32,7 @@ static inline void kaiser_init(void) { } static inline int kaiser_add_mapping(unsigned long addr, -unsigned long size, unsigned long flags) +unsigned long size, u64 flags) { return 0; }
[PATCH 3.2 001/104] brcmfmac: work-around gcc 4.7 build issue
3.2.101-rc1 review patch. If anyone has any objections, please let me know. -- From: Alexandre Oliva commit 5addc0de28f5e286f9d121112c450807b5a5 upstream. Alexandre Oliva says: "It's an issue brought about by GCC 4.7's partial-inlining, that ends up splitting the udelay function just at the wrong spot, in such a way that some sanity checks for constants fails, and we end up calling bad_udelay. This patch fixes the problem. Feel free to push it upstream if it makes sense to you." Signed-off-by: John W. Linville Signed-off-by: Ben Hutchings --- drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c @@ -2465,7 +2465,7 @@ static s32 brcmf_init_iscan(struct brcmf return err; } -static void brcmf_delay(u32 ms) +static __always_inline void brcmf_delay(u32 ms) { if (ms < 1000 / HZ) { cond_resched();
[PATCH 3.2 012/104] usb: renesas_usbhs: fixup __usbhs_for_each_pipe 1st pos
3.2.101-rc1 review patch. If anyone has any objections, please let me know. -- From: Kuninori Morimoto commit c2fa3edc58a262dfcb7aea78e24661e90e00098c upstream. __usbhs_for_each_pipe() is the macro which moves around each pipe, but it has a bug which didn't care about 1st pipe's position. Because of this bug, it moves around pipe0, pipe2, pipe3 ... even though it requested pipe1, pipe2, pipe3... This patch modifies it. Signed-off-by: Kuninori Morimoto Signed-off-by: Felipe Balbi Signed-off-by: Ben Hutchings --- drivers/usb/renesas_usbhs/pipe.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/usb/renesas_usbhs/pipe.h +++ b/drivers/usb/renesas_usbhs/pipe.h @@ -54,7 +54,7 @@ struct usbhs_pipe_info { * pipe list */ #define __usbhs_for_each_pipe(start, pos, info, i) \ - for (i = start, pos = (info)->pipe; \ + for (i = start, pos = (info)->pipe + i; \ i < (info)->size; \ i++, pos = (info)->pipe + i)
[PATCH 3.2 008/104] rtlwifi: rtl8192de: Fix W=1 build warnings
3.2.101-rc1 review patch. If anyone has any objections, please let me know. -- From: Larry Finger commit 8925d518663628f769173d3586c66987fdd3ab61 upstream. when this driver is built with "make W=1", the following warning is printed: drivers/net/wireless/rtlwifi/rtl8192de/dm.c:1058:5: warning: comparison is always false due to limited range of data type [-Wtype-limits] Signed-off-by: Larry Finger Signed-off-by: John W. Linville Signed-off-by: Ben Hutchings --- drivers/net/wireless/rtlwifi/rtl8192de/dm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/drivers/net/wireless/rtlwifi/rtl8192de/dm.c +++ b/drivers/net/wireless/rtlwifi/rtl8192de/dm.c @@ -843,9 +843,9 @@ static void rtl92d_dm_txpower_tracking_c long ele_a = 0, ele_d, temp_cck, val_x, value32; long val_y, ele_c = 0; u8 ofdm_index[2]; - u8 cck_index = 0; + s8 cck_index = 0; u8 ofdm_index_old[2]; - u8 cck_index_old = 0; + s8 cck_index_old = 0; u8 index; int i; bool is2t = IS_92D_SINGLEPHY(rtlhal->version);
[PATCH 3.2 015/104] gcov: add support for gcc 4.7 gcov format
3.2.101-rc1 review patch. If anyone has any objections, please let me know. -- From: Frantisek Hrbata commit 5f41ea0386a53414d688cfcaa321a78310e5f7c1 upstream. The gcov in-memory format changed in gcc 4.7. The biggest change, which requires this special implementation, is that gcov_info no longer contains array of counters for each counter type for all functions and gcov_fn_info is not used for mapping of function's counters to these arrays(offset). Now each gcov_fn_info contans it's counters, which makes things a little bit easier. This is heavily based on the previous gcc_3_4.c implementation and patches provided by Peter Oberparleiter. Specially the buffer gcda implementation for iterator. [a...@linux-foundation.org: use kmemdup() and kcalloc()] [ober...@linux.vnet.ibm.com: gcc_4_7.c needs vmalloc.h] Signed-off-by: Frantisek Hrbata Cc: Jan Stancek Cc: Kees Cook Reviewed-by: Peter Oberparleiter Cc: Rusty Russell Cc: Arnd Bergmann Cc: Andy Gospodarek Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Ben Hutchings --- kernel/gcov/base.c| 6 + kernel/gcov/gcc_4_7.c | 560 ++ 2 files changed, 566 insertions(+) create mode 100644 kernel/gcov/gcc_4_7.c --- a/kernel/gcov/base.c +++ b/kernel/gcov/base.c @@ -79,6 +79,12 @@ void __gcov_merge_delta(gcov_type *count } EXPORT_SYMBOL(__gcov_merge_delta); +void __gcov_merge_ior(gcov_type *counters, unsigned int n_counters) +{ + /* Unused. */ +} +EXPORT_SYMBOL(__gcov_merge_ior); + /** * gcov_enable_events - enable event reporting through gcov_event() * --- /dev/null +++ b/kernel/gcov/gcc_4_7.c @@ -0,0 +1,560 @@ +/* + * This code provides functions to handle gcc's profiling data format + * introduced with gcc 4.7. + * + * This file is based heavily on gcc_3_4.c file. + * + * For a better understanding, refer to gcc source: + * gcc/gcov-io.h + * libgcc/libgcov.c + * + * Uses gcc-internal data definitions. + */ + +#include +#include +#include +#include +#include +#include "gcov.h" + +#define GCOV_COUNTERS 8 +#define GCOV_TAG_FUNCTION_LENGTH 3 + +static struct gcov_info *gcov_info_head; + +/** + * struct gcov_ctr_info - information about counters for a single function + * @num: number of counter values for this type + * @values: array of counter values for this type + * + * This data is generated by gcc during compilation and doesn't change + * at run-time with the exception of the values array. + */ +struct gcov_ctr_info { + unsigned int num; + gcov_type *values; +}; + +/** + * struct gcov_fn_info - profiling meta data per function + * @key: comdat key + * @ident: unique ident of function + * @lineno_checksum: function lineo_checksum + * @cfg_checksum: function cfg checksum + * @ctrs: instrumented counters + * + * This data is generated by gcc during compilation and doesn't change + * at run-time. + * + * Information about a single function. This uses the trailing array + * idiom. The number of counters is determined from the merge pointer + * array in gcov_info. The key is used to detect which of a set of + * comdat functions was selected -- it points to the gcov_info object + * of the object file containing the selected comdat function. + */ +struct gcov_fn_info { + const struct gcov_info *key; + unsigned int ident; + unsigned int lineno_checksum; + unsigned int cfg_checksum; + struct gcov_ctr_info ctrs[0]; +}; + +/** + * struct gcov_info - profiling data per object file + * @version: gcov version magic indicating the gcc version used for compilation + * @next: list head for a singly-linked list + * @stamp: uniquifying time stamp + * @filename: name of the associated gcov data file + * @merge: merge functions (null for unused counter type) + * @n_functions: number of instrumented functions + * @functions: pointer to pointers to function information + * + * This data is generated by gcc during compilation and doesn't change + * at run-time with the exception of the next pointer. + */ +struct gcov_info { + unsigned int version; + struct gcov_info *next; + unsigned int stamp; + const char *filename; + void (*merge[GCOV_COUNTERS])(gcov_type *, unsigned int); + unsigned int n_functions; + struct gcov_fn_info **functions; +}; + +/** + * gcov_info_filename - return info filename + * @info: profiling data set + */ +const char *gcov_info_filename(struct gcov_info *info) +{ + return info->filename; +} + +/** + * gcov_info_version - return info version + * @info: profiling data set + */ +unsigned int gcov_info_version(struct gcov_info *info) +{ + return info->version; +} + +/** + * gcov_info_next - return next profiling data set + * @info: profiling data set + * + * Returns next gcov_info following @info or first gcov_info in the chain if + * @info is %NULL. + */ +struct gcov_info *gcov_info_next(struct gcov_info *info) +
[PATCH 3.2 003/104] rtlwifi: rtl8192se: Fix gcc 4.7.x warning
3.2.101-rc1 review patch. If anyone has any objections, please let me know. -- From: Larry Finger commit f761b6947dde42890beea59b020e1be87491809e upstream. With gcc 4.7.x, the following warning is issued as the routine that sets the array has the possibility of not initializing the values: CC [M] drivers/net/wireless/rtlwifi/rtl8192se/phy.o drivers/net/wireless/rtlwifi/rtl8192se/phy.c: In function ‘rtl92s_phy_set_txpower’: drivers/net/wireless/rtlwifi/rtl8192se/phy.c:1268:23: warning: ‘ofdmpowerLevel[0]’ may be used uninitialized in this function [-Wuninitialized] Signed-off-by: Larry Finger Signed-off-by: John W. Linville Signed-off-by: Ben Hutchings --- drivers/net/wireless/rtlwifi/rtl8192se/phy.c | 3 +++ 1 file changed, 3 insertions(+) --- a/drivers/net/wireless/rtlwifi/rtl8192se/phy.c +++ b/drivers/net/wireless/rtlwifi/rtl8192se/phy.c @@ -1254,6 +1254,9 @@ static void _rtl92s_phy_get_txpower_inde /* Read HT 40 OFDM TX power */ ofdmpowerLevel[0] = rtlefuse->txpwrlevel_ht40_2s[0][index]; ofdmpowerLevel[1] = rtlefuse->txpwrlevel_ht40_2s[1][index]; + } else { + ofdmpowerLevel[0] = 0; + ofdmpowerLevel[1] = 0; } }
[PATCH 3.2 013/104] usb: renesas_usbhs: tidyup original usbhsx_for_each_xxx macro
3.2.101-rc1 review patch. If anyone has any objections, please let me know. -- From: Kuninori Morimoto commit 925403f425a4a9c503f2fc295652647b1eb10d82 upstream. Current usbhsx_for_each_xxx macro will read out-of-array's memory after last loop operation. It was not good C language operation, and the binary which was compiled by (at least) gcc 4.8.1 is broken This patch tidyup these issues Reported-by: Yusuke Goda Reviewed-by: Takashi Yoshii Signed-off-by: Kuninori Morimoto Signed-off-by: Felipe Balbi Signed-off-by: Ben Hutchings --- drivers/usb/renesas_usbhs/mod_gadget.c | 6 +++--- drivers/usb/renesas_usbhs/mod_host.c | 6 +++--- drivers/usb/renesas_usbhs/pipe.h | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) --- a/drivers/usb/renesas_usbhs/mod_gadget.c +++ b/drivers/usb/renesas_usbhs/mod_gadget.c @@ -76,9 +76,9 @@ struct usbhsg_recip_handle { struct usbhsg_gpriv, mod) #define __usbhsg_for_each_uep(start, pos, g, i)\ - for (i = start, pos = (g)->uep + i; \ -i < (g)->uep_size; \ -i++, pos = (g)->uep + i) + for ((i) = start; \ +((i) < (g)->uep_size) && ((pos) = (g)->uep + (i)); \ +(i)++) #define usbhsg_for_each_uep(pos, gpriv, i) \ __usbhsg_for_each_uep(1, pos, gpriv, i) --- a/drivers/usb/renesas_usbhs/mod_host.c +++ b/drivers/usb/renesas_usbhs/mod_host.c @@ -131,9 +131,9 @@ static const char usbhsh_hcd_name[] = "r __usbhsh_for_each_hpipe(0, pos, hpriv, i) #define __usbhsh_for_each_udev(start, pos, h, i) \ - for (i = start, pos = (h)->udev + i;\ -i < USBHSH_DEVICE_MAX; \ -i++, pos = (h)->udev + i) + for ((i) = start; \ +((i) < USBHSH_DEVICE_MAX) && ((pos) = (h)->udev + (i));\ +(i)++) #define usbhsh_for_each_udev(pos, hpriv, i)\ __usbhsh_for_each_udev(1, pos, hpriv, i) --- a/drivers/usb/renesas_usbhs/pipe.h +++ b/drivers/usb/renesas_usbhs/pipe.h @@ -54,9 +54,9 @@ struct usbhs_pipe_info { * pipe list */ #define __usbhs_for_each_pipe(start, pos, info, i) \ - for (i = start, pos = (info)->pipe + i; \ -i < (info)->size; \ -i++, pos = (info)->pipe + i) + for ((i) = start; \ +((i) < (info)->size) && ((pos) = (info)->pipe + (i)); \ +(i)++) #define usbhs_for_each_pipe(pos, priv, i) \ __usbhs_for_each_pipe(1, pos, &((priv)->pipe_info), i)
Re: [v6-1,15/17] arm64: dts: rockchip: add isp0 node for rk3399
Ah, sorry, I used a wrong Message-Id in In-reply-to, please ignore this one. Sorry about that. On 2018年03月12日 11:37, Shunqian Zheng wrote: rk3399 have two ISP, but we havn't test isp1, so just add isp0 at present. Signed-off-by: Shunqian Zheng Signed-off-by: Jacob Chen --- arch/arm64/boot/dts/rockchip/rk3399.dtsi | 18 ++ 1 file changed, 18 insertions(+) diff --git a/arch/arm64/boot/dts/rockchip/rk3399.dtsi b/arch/arm64/boot/dts/rockchip/rk3399.dtsi index 2605118..5729786 100644 --- a/arch/arm64/boot/dts/rockchip/rk3399.dtsi +++ b/arch/arm64/boot/dts/rockchip/rk3399.dtsi @@ -1614,6 +1614,24 @@ status = "disabled"; }; + isp0: isp0@ff91 { + compatible = "rockchip,rk3399-cif-isp"; + reg = <0x0 0xff91 0x0 0x4000>; + interrupts = ; + clocks = <&cru SCLK_ISP0>, +<&cru ACLK_ISP0>, <&cru ACLK_ISP0_WRAPPER>, +<&cru HCLK_ISP0>, <&cru HCLK_ISP0_WRAPPER>; + clock-names = "clk_isp", + "aclk_isp", "aclk_isp_wrap", + "hclk_isp", "hclk_isp_wrap"; + assigned-clocks = <&cru SCLK_ISP0>, <&cru ACLK_ISP0>; + assigned-clock-rates = <5>, <4>; + + power-domains = <&power RK3399_PD_ISP0>; + iommus = <&isp0_mmu>; + status = "disabled"; + }; + isp0_mmu: iommu@ff914000 { compatible = "rockchip,iommu"; reg = <0x0 0xff914000 0x0 0x100>, <0x0 0xff915000 0x0 0x100>;
[PATCH 3.2 095/104] x86/speculation: Fix typo IBRS_ATT, which should be IBRS_ALL
3.2.101-rc1 review patch. If anyone has any objections, please let me know. -- From: Darren Kenny commit af189c95a371b59f493dbe0f50c0a09724868881 upstream. Fixes: 117cc7a908c83 ("x86/retpoline: Fill return stack buffer on vmexit") Signed-off-by: Darren Kenny Signed-off-by: Thomas Gleixner Reviewed-by: Konrad Rzeszutek Wilk Cc: Tom Lendacky Cc: Andi Kleen Cc: Borislav Petkov Cc: Masami Hiramatsu Cc: Arjan van de Ven Cc: David Woodhouse Link: https://lkml.kernel.org/r/20180202191220.blvgkgutojecx...@starbug-vm.ie.oracle.com Signed-off-by: Ben Hutchings --- arch/x86/include/asm/nospec-branch.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/arch/x86/include/asm/nospec-branch.h +++ b/arch/x86/include/asm/nospec-branch.h @@ -179,7 +179,7 @@ extern char __indirect_thunk_size[]; * On VMEXIT we must ensure that no RSB predictions learned in the guest * can be followed in the host, by overwriting the RSB completely. Both * retpoline and IBRS mitigations for Spectre v2 need this; only on future - * CPUs with IBRS_ATT *might* it be avoided. + * CPUs with IBRS_ALL *might* it be avoided. */ static inline void vmexit_fill_RSB(void) {
[PATCH 3.2 014/104] gcov: move gcov structs definitions to a gcc version specific file
3.2.101-rc1 review patch. If anyone has any objections, please let me know. -- From: Frantisek Hrbata commit 8cbce376e3fdf4a21f59365aefbb52eac3c2e312 upstream. Since also the gcov structures(gcov_info, gcov_fn_info, gcov_ctr_info) can change between gcc releases, as shown in gcc 4.7, they cannot be defined in a common header and need to be moved to a specific gcc implemention file. This also requires to make the gcov_info structure opaque for the common code and to introduce simple helpers for accessing data inside gcov_info. Signed-off-by: Frantisek Hrbata Cc: Jan Stancek Cc: Kees Cook Acked-by: Peter Oberparleiter Cc: Rusty Russell Cc: Arnd Bergmann Cc: Andy Gospodarek Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Ben Hutchings --- kernel/gcov/base.c| 26 ++-- kernel/gcov/fs.c | 27 ++-- kernel/gcov/gcc_3_4.c | 115 ++ kernel/gcov/gcov.h| 65 +--- 4 files changed, 153 insertions(+), 80 deletions(-) --- a/kernel/gcov/base.c +++ b/kernel/gcov/base.c @@ -20,7 +20,6 @@ #include #include "gcov.h" -static struct gcov_info *gcov_info_head; static int gcov_events_enabled; static DEFINE_MUTEX(gcov_lock); @@ -34,7 +33,7 @@ void __gcov_init(struct gcov_info *info) mutex_lock(&gcov_lock); if (gcov_version == 0) { - gcov_version = info->version; + gcov_version = gcov_info_version(info); /* * Printing gcc's version magic may prove useful for debugging * incompatibility reports. @@ -45,8 +44,7 @@ void __gcov_init(struct gcov_info *info) * Add new profiling data structure to list and inform event * listener. */ - info->next = gcov_info_head; - gcov_info_head = info; + gcov_info_link(info); if (gcov_events_enabled) gcov_event(GCOV_ADD, info); mutex_unlock(&gcov_lock); @@ -91,13 +89,15 @@ EXPORT_SYMBOL(__gcov_merge_delta); */ void gcov_enable_events(void) { - struct gcov_info *info; + struct gcov_info *info = NULL; mutex_lock(&gcov_lock); gcov_events_enabled = 1; + /* Perform event callback for previously registered entries. */ - for (info = gcov_info_head; info; info = info->next) + while ((info = gcov_info_next(info))) gcov_event(GCOV_ADD, info); + mutex_unlock(&gcov_lock); } @@ -112,25 +112,23 @@ static int gcov_module_notifier(struct n void *data) { struct module *mod = data; - struct gcov_info *info; - struct gcov_info *prev; + struct gcov_info *info = NULL; + struct gcov_info *prev = NULL; if (event != MODULE_STATE_GOING) return NOTIFY_OK; mutex_lock(&gcov_lock); - prev = NULL; + /* Remove entries located in module from linked list. */ - for (info = gcov_info_head; info; info = info->next) { + while ((info = gcov_info_next(info))) { if (within(info, mod->module_core, mod->core_size)) { - if (prev) - prev->next = info->next; - else - gcov_info_head = info->next; + gcov_info_unlink(prev, info); if (gcov_events_enabled) gcov_event(GCOV_REMOVE, info); } else prev = info; } + mutex_unlock(&gcov_lock); return NOTIFY_OK; --- a/kernel/gcov/fs.c +++ b/kernel/gcov/fs.c @@ -242,7 +242,7 @@ static struct gcov_node *get_node_by_nam list_for_each_entry(node, &all_head, all) { info = get_node_info(node); - if (info && (strcmp(info->filename, name) == 0)) + if (info && (strcmp(gcov_info_filename(info), name) == 0)) return node; } @@ -279,7 +279,7 @@ static ssize_t gcov_seq_write(struct fil seq = file->private_data; info = gcov_iter_get_info(seq->private); mutex_lock(&node_lock); - node = get_node_by_name(info->filename); + node = get_node_by_name(gcov_info_filename(info)); if (node) { /* Reset counts or remove node for unloaded modules. */ if (node->num_loaded == 0) @@ -376,8 +376,9 @@ static void add_links(struct gcov_node * if (!node->links) return; for (i = 0; i < num; i++) { - target = get_link_target(get_node_info(node)->filename, -&gcov_link[i]); + target = get_link_target( + gcov_info_filename(get_node_info(node)), + &gcov_link[i]); if (!target) goto out_err;
[PATCH 3.2 016/104] gcov: compile specific gcov implementation based on gcc version
3.2.101-rc1 review patch. If anyone has any objections, please let me know. -- From: Frantisek Hrbata commit 17c568d60af5a810208baf116dc174a2005c6c3e upstream. Compile the correct gcov implementation file for the specific gcc version. Signed-off-by: Frantisek Hrbata Cc: Jan Stancek Cc: Kees Cook Acked-by: Peter Oberparleiter Cc: Rusty Russell Cc: Arnd Bergmann Cc: Andy Gospodarek Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Ben Hutchings --- Documentation/gcov.txt | 4 kernel/gcov/Kconfig| 30 ++ kernel/gcov/Makefile | 32 +++- 3 files changed, 65 insertions(+), 1 deletion(-) --- a/Documentation/gcov.txt +++ b/Documentation/gcov.txt @@ -50,6 +50,10 @@ Configure the kernel with: CONFIG_DEBUG_FS=y CONFIG_GCOV_KERNEL=y +select the gcc's gcov format, default is autodetect based on gcc version: + +CONFIG_GCOV_FORMAT_AUTODETECT=y + and to get coverage data for the entire kernel: CONFIG_GCOV_PROFILE_ALL=y --- a/kernel/gcov/Kconfig +++ b/kernel/gcov/Kconfig @@ -46,4 +46,34 @@ config GCOV_PROFILE_ALL larger and run slower. Also be sure to exclude files from profiling which are not linked to the kernel image to prevent linker errors. +choice + prompt "Specify GCOV format" + depends on GCOV_KERNEL + default GCOV_FORMAT_AUTODETECT + ---help--- + The gcov format is usually determined by the GCC version, but there are + exceptions where format changes are integrated in lower-version GCCs. + In such a case use this option to adjust the format used in the kernel + accordingly. + + If unsure, choose "Autodetect". + +config GCOV_FORMAT_AUTODETECT + bool "Autodetect" + ---help--- + Select this option to use the format that corresponds to your GCC + version. + +config GCOV_FORMAT_3_4 + bool "GCC 3.4 format" + ---help--- + Select this option to use the format defined by GCC 3.4. + +config GCOV_FORMAT_4_7 + bool "GCC 4.7 format" + ---help--- + Select this option to use the format defined by GCC 4.7. + +endchoice + endmenu --- a/kernel/gcov/Makefile +++ b/kernel/gcov/Makefile @@ -1,3 +1,33 @@ ccflags-y := -DSRCTREE='"$(srctree)"' -DOBJTREE='"$(objtree)"' -obj-$(CONFIG_GCOV_KERNEL) := base.o fs.o gcc_3_4.o +# if-lt +# Usage VAR := $(call if-lt, $(a), $(b)) +# Returns 1 if (a < b) +if-lt = $(shell [ $(1) -lt $(2) ] && echo 1) + +ifeq ($(CONFIG_GCOV_FORMAT_3_4),y) + cc-ver := 0304 +else ifeq ($(CONFIG_GCOV_FORMAT_4_7),y) + cc-ver := 0407 +else +# Use cc-version if available, otherwise set 0 +# +# scripts/Kbuild.include, which contains cc-version function, is not included +# during make clean "make -f scripts/Makefile.clean obj=kernel/gcov" +# Meaning cc-ver is empty causing if-lt test to fail with +# "/bin/sh: line 0: [: -lt: unary operator expected" error mesage. +# This has no affect on the clean phase, but the error message could be +# confusing/annoying. So this dummy workaround sets cc-ver to zero if cc-version +# is not available. We can probably move if-lt to Kbuild.include, so it's also +# not defined during clean or to include Kbuild.include in +# scripts/Makefile.clean. But the following workaround seems least invasive. + cc-ver := $(if $(call cc-version),$(call cc-version),0) +endif + +obj-$(CONFIG_GCOV_KERNEL) := base.o fs.o + +ifeq ($(call if-lt, $(cc-ver), 0407),1) + obj-$(CONFIG_GCOV_KERNEL) += gcc_3_4.o +else + obj-$(CONFIG_GCOV_KERNEL) += gcc_4_7.o +endif
[PATCH 3.2 002/104] Bluetooth: Remove unused hci_le_ltk_reply()
3.2.101-rc1 review patch. If anyone has any objections, please let me know. -- From: Syam Sidhardhan commit e10b9969f217c948c5523045f44eba4d3a758ff0 upstream. In this API, we were using sizeof operator for an array given as function argument, which is invalid. However this API is not used anywhere. Signed-off-by: Syam Sidhardhan Signed-off-by: Gustavo Padovan Signed-off-by: Ben Hutchings --- include/net/bluetooth/hci_core.h | 1 - net/bluetooth/hci_conn.c | 16 2 files changed, 17 deletions(-) --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -912,7 +912,6 @@ void hci_le_conn_update(struct hci_conn u16 latency, u16 to_multiplier); void hci_le_start_enc(struct hci_conn *conn, __le16 ediv, __u8 rand[8], __u8 ltk[16]); -void hci_le_ltk_reply(struct hci_conn *conn, u8 ltk[16]); void hci_le_ltk_neg_reply(struct hci_conn *conn); #endif /* __HCI_CORE_H */ --- a/net/bluetooth/hci_conn.c +++ b/net/bluetooth/hci_conn.c @@ -225,22 +225,6 @@ void hci_le_start_enc(struct hci_conn *c } EXPORT_SYMBOL(hci_le_start_enc); -void hci_le_ltk_reply(struct hci_conn *conn, u8 ltk[16]) -{ - struct hci_dev *hdev = conn->hdev; - struct hci_cp_le_ltk_reply cp; - - BT_DBG("%p", conn); - - memset(&cp, 0, sizeof(cp)); - - cp.handle = cpu_to_le16(conn->handle); - memcpy(cp.ltk, ltk, sizeof(ltk)); - - hci_send_cmd(hdev, HCI_OP_LE_LTK_REPLY, sizeof(cp), &cp); -} -EXPORT_SYMBOL(hci_le_ltk_reply); - void hci_le_ltk_neg_reply(struct hci_conn *conn) { struct hci_dev *hdev = conn->hdev;
[PATCH 3.2 011/104] Removed unused typedef to avoid "unused local typedef" warnings.
3.2.101-rc1 review patch. If anyone has any objections, please let me know. -- From: Han Shen commit 6b13eb1baa17b8746f96bd536d2897ec86e823d9 upstream. Fix warnings about unused local typedefs (reported by gcc 4.8). Signed-off-by: Han Shen (shen...@google.com) Change-Id: I4bccc234f1390daa808d2b309ed112e20c0ac096 Signed-off-by: Al Viro Signed-off-by: Ben Hutchings --- fs/compat_ioctl.c | 1 - 1 file changed, 1 deletion(-) --- a/fs/compat_ioctl.c +++ b/fs/compat_ioctl.c @@ -608,7 +608,6 @@ struct serial_struct32 { static int serial_struct_ioctl(unsigned fd, unsigned cmd, struct serial_struct32 __user *ss32) { -typedef struct serial_struct SS; typedef struct serial_struct32 SS32; int err; struct serial_struct ss;
[PATCH 3.2 017/104] SELinux: security_load_policy: Silence frame-larger-than warning
3.2.101-rc1 review patch. If anyone has any objections, please let me know. -- From: Tim Gardner commit b5495b4217d3fa64deac479db83dbede149af7d8 upstream. Dynamically allocate a couple of the larger stack variables in order to reduce the stack footprint below 1024. gcc-4.8 security/selinux/ss/services.c: In function 'security_load_policy': security/selinux/ss/services.c:1964:1: warning: the frame size of 1104 bytes is larger than 1024 bytes [-Wframe-larger-than=] } Also silence a couple of checkpatch warnings at the same time. WARNING: sizeof policydb should be sizeof(policydb) + memcpy(oldpolicydb, &policydb, sizeof policydb); WARNING: sizeof policydb should be sizeof(policydb) + memcpy(&policydb, newpolicydb, sizeof policydb); Cc: Stephen Smalley Cc: James Morris Cc: Eric Paris Signed-off-by: Tim Gardner Signed-off-by: Paul Moore Signed-off-by: Ben Hutchings --- security/selinux/ss/services.c | 54 +- 1 file changed, 32 insertions(+), 22 deletions(-) --- a/security/selinux/ss/services.c +++ b/security/selinux/ss/services.c @@ -1806,7 +1806,7 @@ static int security_preserve_bools(struc */ int security_load_policy(void *data, size_t len) { - struct policydb oldpolicydb, newpolicydb; + struct policydb *oldpolicydb, *newpolicydb; struct sidtab oldsidtab, newsidtab; struct selinux_mapping *oldmap, *map = NULL; struct convert_context_args args; @@ -1815,12 +1815,19 @@ int security_load_policy(void *data, siz int rc = 0; struct policy_file file = { data, len }, *fp = &file; + oldpolicydb = kzalloc(2 * sizeof(*oldpolicydb), GFP_KERNEL); + if (!oldpolicydb) { + rc = -ENOMEM; + goto out; + } + newpolicydb = oldpolicydb + 1; + if (!ss_initialized) { avtab_cache_init(); rc = policydb_read(&policydb, fp); if (rc) { avtab_cache_destroy(); - return rc; + goto out; } policydb.len = len; @@ -1830,14 +1837,14 @@ int security_load_policy(void *data, siz if (rc) { policydb_destroy(&policydb); avtab_cache_destroy(); - return rc; + goto out; } rc = policydb_load_isids(&policydb, &sidtab); if (rc) { policydb_destroy(&policydb); avtab_cache_destroy(); - return rc; + goto out; } security_load_policycaps(); @@ -1849,36 +1856,36 @@ int security_load_policy(void *data, siz selinux_status_update_policyload(seqno); selinux_netlbl_cache_invalidate(); selinux_xfrm_notify_policyload(); - return 0; + goto out; } #if 0 sidtab_hash_eval(&sidtab, "sids"); #endif - rc = policydb_read(&newpolicydb, fp); + rc = policydb_read(newpolicydb, fp); if (rc) - return rc; + goto out; - newpolicydb.len = len; + newpolicydb->len = len; /* If switching between different policy types, log MLS status */ - if (policydb.mls_enabled && !newpolicydb.mls_enabled) + if (policydb.mls_enabled && !newpolicydb->mls_enabled) printk(KERN_INFO "SELinux: Disabling MLS support...\n"); - else if (!policydb.mls_enabled && newpolicydb.mls_enabled) + else if (!policydb.mls_enabled && newpolicydb->mls_enabled) printk(KERN_INFO "SELinux: Enabling MLS support...\n"); - rc = policydb_load_isids(&newpolicydb, &newsidtab); + rc = policydb_load_isids(newpolicydb, &newsidtab); if (rc) { printk(KERN_ERR "SELinux: unable to load the initial SIDs\n"); - policydb_destroy(&newpolicydb); - return rc; + policydb_destroy(newpolicydb); + goto out; } - rc = selinux_set_mapping(&newpolicydb, secclass_map, &map, &map_size); + rc = selinux_set_mapping(newpolicydb, secclass_map, &map, &map_size); if (rc) goto err; - rc = security_preserve_bools(&newpolicydb); + rc = security_preserve_bools(newpolicydb); if (rc) { printk(KERN_ERR "SELinux: unable to preserve booleans\n"); goto err; @@ -1896,7 +1903,7 @@ int security_load_policy(void *data, siz * in the new SID table. */ args.oldp = &policydb; - args.newp = &newpolicydb; + args.newp = newpolicydb; rc = sidtab_map(&newsidtab, convert_context, &args); if (rc) { printk(KERN_ERR "SELinux: unable to convert the internal" @@ -1906,12 +1913,12 @@
[PATCH 3.2 070/104] kprobes/x86: Blacklist indirect thunk functions for kprobes
3.2.101-rc1 review patch. If anyone has any objections, please let me know. -- From: Masami Hiramatsu commit c1804a236894ecc942da7dc6c5abe209e56cba93 upstream. Mark __x86_indirect_thunk_* functions as blacklist for kprobes because those functions can be called from anywhere in the kernel including blacklist functions of kprobes. Signed-off-by: Masami Hiramatsu Signed-off-by: Thomas Gleixner Acked-by: David Woodhouse Cc: Andi Kleen Cc: Peter Zijlstra Cc: Ananth N Mavinakayanahalli Cc: Arjan van de Ven Cc: Greg Kroah-Hartman Link: https://lkml.kernel.org/r/151629209111.10241.5444852823378068683.stgit@devbox [bwh: Backported to 3.2: We don't have _ASM_NOKPROBE etc., so add indirect thunks to the built-in blacklist] Signed-off-by: Ben Hutchings --- --- a/kernel/kprobes.c +++ b/kernel/kprobes.c @@ -53,6 +53,9 @@ #include #include #include +#ifdef CONFIG_RETPOLINE +#include +#endif #define KPROBE_HASH_BITS 6 #define KPROBE_TABLE_SIZE (1 << KPROBE_HASH_BITS) @@ -99,6 +102,11 @@ static struct kprobe_blackpoint kprobe_b {"irq_entries_start",}, {"common_interrupt",}, {"mcount",},/* mcount can be called from everywhere */ +#ifdef CONFIG_RETPOLINE + {"__indirect_thunk_start", +/* Linker scripts can't set symbol sizes */ +.range = (size_t)__indirect_thunk_size}, +#endif {NULL}/* Terminator */ }; @@ -1986,7 +1994,7 @@ static int __init init_kprobes(void) &size, &offset, &modname, namebuf); if (!symbol_name) kb->range = 0; - else + else if (size) kb->range = size; } --- a/arch/x86/include/asm/nospec-branch.h +++ b/arch/x86/include/asm/nospec-branch.h @@ -173,6 +173,7 @@ enum spectre_v2_mitigation { extern char __indirect_thunk_start[]; extern char __indirect_thunk_end[]; +extern char __indirect_thunk_size[]; /* * On VMEXIT we must ensure that no RSB predictions learned in the guest --- a/arch/x86/kernel/vmlinux.lds.S +++ b/arch/x86/kernel/vmlinux.lds.S @@ -112,6 +112,7 @@ SECTIONS __indirect_thunk_start = .; *(.text.__x86.indirect_thunk) __indirect_thunk_end = .; + __indirect_thunk_size = __indirect_thunk_end - __indirect_thunk_start; #endif /* End of text section */
[PATCH char-misc 1/1] Drivers: hv: vmbus: Add hooks for per-CPU IRQ
Add hooks to enable/disable a per-CPU IRQ for VMbus. These hooks are in the architecture independent setup and shutdown paths for Hyper-V. They are being added as staging for upcoming code for Linux guests on Hyper-V on ARM64. The x86/x64 implementation is null because VMbus interrupts on x86/x64 don't use an IRQ. Signed-off-by: Michael Kelley --- arch/x86/include/asm/mshyperv.h | 4 drivers/hv/hv.c | 2 ++ 2 files changed, 6 insertions(+) diff --git a/arch/x86/include/asm/mshyperv.h b/arch/x86/include/asm/mshyperv.h index e73c4d0..b73b839 100644 --- a/arch/x86/include/asm/mshyperv.h +++ b/arch/x86/include/asm/mshyperv.h @@ -168,6 +168,10 @@ void hyperv_vector_handler(struct pt_regs *regs); void hv_setup_vmbus_irq(void (*handler)(void)); void hv_remove_vmbus_irq(void); +/* On x86/x64, there isn't a real IRQ to be enabled/disabled */ +static inline void hv_enable_vmbus_irq(void) {} +static inline void hv_disable_vmbus_irq(void) {} + void hv_setup_kexec_handler(void (*handler)(void)); void hv_remove_kexec_handler(void); void hv_setup_crash_handler(void (*handler)(struct pt_regs *regs)); diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c index b1f6793..6a3ea4e 100644 --- a/drivers/hv/hv.c +++ b/drivers/hv/hv.c @@ -299,6 +299,7 @@ int hv_synic_init(unsigned int cpu) hv_set_siefp(siefp.as_uint64); /* Setup the shared SINT. */ + hv_enable_vmbus_irq(); hv_get_synint_state(HV_X64_MSR_SINT0 + VMBUS_MESSAGE_SINT, shared_sint.as_uint64); @@ -433,6 +434,7 @@ int hv_synic_cleanup(unsigned int cpu) hv_get_synic_state(sctrl.as_uint64); sctrl.enable = 0; hv_set_synic_state(sctrl.as_uint64); + hv_disable_vmbus_irq(); return 0; } -- 2.7.4
[PATCH 3.2 080/104] x86/cpu/bugs: Make retpoline module warning conditional
3.2.101-rc1 review patch. If anyone has any objections, please let me know. -- From: Thomas Gleixner commit e383095c7fe8d218e00ec0f83e4b95ed4e627b02 upstream. If sysfs is disabled and RETPOLINE not defined: arch/x86/kernel/cpu/bugs.c:97:13: warning: ‘spectre_v2_bad_module’ defined but not used [-Wunused-variable] static bool spectre_v2_bad_module; Hide it. Fixes: caf7501a1b4e ("module/retpoline: Warn about missing retpoline in module") Reported-by: Borislav Petkov Signed-off-by: Thomas Gleixner Cc: Andi Kleen Cc: David Woodhouse [bwh: Backported to 3.2: adjust context] Signed-off-by: Ben Hutchings --- arch/x86/kernel/cpu/bugs.c | 14 +++--- 1 file changed, 11 insertions(+), 3 deletions(-) --- a/arch/x86/kernel/cpu/bugs.c +++ b/arch/x86/kernel/cpu/bugs.c @@ -236,9 +236,10 @@ static const char *spectre_v2_strings[] #define pr_fmt(fmt) "Spectre V2 : " fmt static enum spectre_v2_mitigation spectre_v2_enabled = SPECTRE_V2_NONE; -static bool spectre_v2_bad_module; #ifdef RETPOLINE +static bool spectre_v2_bad_module; + bool retpoline_module_ok(bool has_retpoline) { if (spectre_v2_enabled == SPECTRE_V2_NONE || has_retpoline) @@ -248,6 +249,13 @@ bool retpoline_module_ok(bool has_retpol spectre_v2_bad_module = true; return false; } + +static inline const char *spectre_v2_module_string(void) +{ + return spectre_v2_bad_module ? " - vulnerable module loaded" : ""; +} +#else +static inline const char *spectre_v2_module_string(void) { return ""; } #endif static void __init spec2_print_if_insecure(const char *reason) @@ -435,6 +443,6 @@ ssize_t cpu_show_spectre_v2(struct sysde return sprintf(buf, "Not affected\n"); return sprintf(buf, "%s%s\n", spectre_v2_strings[spectre_v2_enabled], - spectre_v2_bad_module ? " - vulnerable module loaded" : ""); + spectre_v2_module_string()); } #endif
[PATCH v6-1,15/17] arm64: dts: rockchip: add isp0 node for rk3399
rk3399 have two ISP, but we havn't test isp1, so just add isp0 at present. Signed-off-by: Shunqian Zheng Signed-off-by: Jacob Chen --- arch/arm64/boot/dts/rockchip/rk3399.dtsi | 18 ++ 1 file changed, 18 insertions(+) diff --git a/arch/arm64/boot/dts/rockchip/rk3399.dtsi b/arch/arm64/boot/dts/rockchip/rk3399.dtsi index 2605118..5729786 100644 --- a/arch/arm64/boot/dts/rockchip/rk3399.dtsi +++ b/arch/arm64/boot/dts/rockchip/rk3399.dtsi @@ -1614,6 +1614,24 @@ status = "disabled"; }; + isp0: isp0@ff91 { + compatible = "rockchip,rk3399-cif-isp"; + reg = <0x0 0xff91 0x0 0x4000>; + interrupts = ; + clocks = <&cru SCLK_ISP0>, +<&cru ACLK_ISP0>, <&cru ACLK_ISP0_WRAPPER>, +<&cru HCLK_ISP0>, <&cru HCLK_ISP0_WRAPPER>; + clock-names = "clk_isp", + "aclk_isp", "aclk_isp_wrap", + "hclk_isp", "hclk_isp_wrap"; + assigned-clocks = <&cru SCLK_ISP0>, <&cru ACLK_ISP0>; + assigned-clock-rates = <5>, <4>; + + power-domains = <&power RK3399_PD_ISP0>; + iommus = <&isp0_mmu>; + status = "disabled"; + }; + isp0_mmu: iommu@ff914000 { compatible = "rockchip,iommu"; reg = <0x0 0xff914000 0x0 0x100>, <0x0 0xff915000 0x0 0x100>; -- 1.9.1
[PATCH 3.2 093/104] x86/retpoline: Avoid retpolines for built-in __init functions
3.2.101-rc1 review patch. If anyone has any objections, please let me know. -- From: David Woodhouse commit 66f793099a636862a71c59d4a6ba91387b155e0c upstream. There's no point in building init code with retpolines, since it runs before any potentially hostile userspace does. And before the retpoline is actually ALTERNATIVEd into place, for much of it. Signed-off-by: David Woodhouse Signed-off-by: Thomas Gleixner Cc: karah...@amazon.de Cc: pet...@infradead.org Cc: b...@alien8.de Link: https://lkml.kernel.org/r/1517484441-1420-2-git-send-email-d...@amazon.co.uk [bwh: Backported to 3.2: adjust context] Signed-off-by: Ben Hutchings --- include/linux/init.h | 9 - 1 file changed, 8 insertions(+), 1 deletion(-) --- a/include/linux/init.h +++ b/include/linux/init.h @@ -3,6 +3,13 @@ #include +/* Built-in __init functions needn't be compiled with retpoline */ +#if defined(RETPOLINE) && !defined(MODULE) +#define __noretpoline __attribute__((indirect_branch("keep"))) +#else +#define __noretpoline +#endif + /* These macros are used to mark some functions or * initialized data (doesn't apply to uninitialized data) * as `initialization' functions. The kernel can take this @@ -40,7 +47,7 @@ /* These are for everybody (although not all archs will actually discard it in modules) */ -#define __init __section(.init.text) __cold notrace +#define __init __section(.init.text) __cold notrace __noretpoline #define __initdata __section(.init.data) #define __initconst__section(.init.rodata) #define __exitdata __section(.exit.data)
[PATCH 3.2 072/104] x86/pti: Document fix wrong index
3.2.101-rc1 review patch. If anyone has any objections, please let me know. -- From: "zhenwei.pi" commit 98f0fceec7f84d80bc053e49e596088573086421 upstream. In section <2. Runtime Cost>, fix wrong index. Signed-off-by: zhenwei.pi Signed-off-by: Thomas Gleixner Cc: dave.han...@linux.intel.com Link: https://lkml.kernel.org/r/1516237492-27739-1-git-send-email-zhenwei...@youruncloud.com Signed-off-by: Ben Hutchings --- Documentation/x86/pti.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/Documentation/x86/pti.txt +++ b/Documentation/x86/pti.txt @@ -78,7 +78,7 @@ this protection comes at a cost: non-PTI SYSCALL entry code, so requires mapping fewer things into the userspace page tables. The downside is that stacks must be switched at entry time. - d. Global pages are disabled for all kernel structures not + c. Global pages are disabled for all kernel structures not mapped into both kernel and userspace page tables. This feature of the MMU allows different processes to share TLB entries mapping the kernel. Losing the feature means more
[PATCH 3.2 076/104] x86/retpoline: Remove the esp/rsp thunk
3.2.101-rc1 review patch. If anyone has any objections, please let me know. -- From: Waiman Long commit 1df37383a8aeabb9b418698f0bcdffea01f4b1b2 upstream. It doesn't make sense to have an indirect call thunk with esp/rsp as retpoline code won't work correctly with the stack pointer register. Removing it will help compiler writers to catch error in case such a thunk call is emitted incorrectly. Fixes: 76b043848fd2 ("x86/retpoline: Add initial retpoline support") Suggested-by: Jeff Law Signed-off-by: Waiman Long Signed-off-by: Thomas Gleixner Acked-by: David Woodhouse Cc: Tom Lendacky Cc: Kees Cook Cc: Andi Kleen Cc: Tim Chen Cc: Peter Zijlstra Cc: Linus Torvalds Cc: Jiri Kosina Cc: Andy Lutomirski Cc: Dave Hansen Cc: Josh Poimboeuf Cc: Arjan van de Ven Cc: Greg Kroah-Hartman Cc: Paul Turner Link: https://lkml.kernel.org/r/1516658974-27852-1-git-send-email-long...@redhat.com [bwh: Backported to 3.2: adjust filename] Signed-off-by: Ben Hutchings --- arch/x86/lib/retpoline-export.c | 1 - arch/x86/lib/retpoline.S| 1 - 2 files changed, 2 deletions(-) --- a/arch/x86/lib/retpoline-export.c +++ b/arch/x86/lib/retpoline-export.c @@ -22,5 +22,4 @@ INDIRECT_THUNK(dx) INDIRECT_THUNK(si) INDIRECT_THUNK(di) INDIRECT_THUNK(bp) -INDIRECT_THUNK(sp) #endif /* CONFIG_RETPOLINE */ --- a/arch/x86/lib/retpoline.S +++ b/arch/x86/lib/retpoline.S @@ -35,7 +35,6 @@ GENERATE_THUNK(_ASM_DX) GENERATE_THUNK(_ASM_SI) GENERATE_THUNK(_ASM_DI) GENERATE_THUNK(_ASM_BP) -GENERATE_THUNK(_ASM_SP) #ifdef CONFIG_64BIT GENERATE_THUNK(r8) GENERATE_THUNK(r9)
[PATCH 3.2 057/104] x86/asm: Use register variable to get stack pointer value
3.2.101-rc1 review patch. If anyone has any objections, please let me know. -- From: Andrey Ryabinin commit 196bd485ee4f03ce4c690bfcf38138abfcd0a4bc upstream. Currently we use current_stack_pointer() function to get the value of the stack pointer register. Since commit: f5caf621ee35 ("x86/asm: Fix inline asm call constraints for Clang") ... we have a stack register variable declared. It can be used instead of current_stack_pointer() function which allows to optimize away some excessive "mov %rsp, %" instructions: -mov%rsp,%rdx -sub%rdx,%rax -cmp$0x3fff,%rax -ja 810722fd +sub%rsp,%rax +cmp$0x3fff,%rax +ja 810722fa Remove current_stack_pointer(), rename __asm_call_sp to current_stack_pointer and use it instead of the removed function. Signed-off-by: Andrey Ryabinin Reviewed-by: Josh Poimboeuf Cc: Andy Lutomirski Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Link: http://lkml.kernel.org/r/20170929141537.29167-1-aryabi...@virtuozzo.com Signed-off-by: Ingo Molnar [dwmw2: We want ASM_CALL_CONSTRAINT for retpoline] Signed-off-by: David Woodhouse Signed-off-by: Razvan Ghitulete Signed-off-by: Greg Kroah-Hartman [bwh: Backported to 3.2: current_stack_pointer was never changed to a function, but was only defined for x86_32] Signed-off-by: Ben Hutchings --- --- a/arch/x86/include/asm/asm.h +++ b/arch/x86/include/asm/asm.h @@ -59,4 +59,15 @@ " .previous\n" #endif +#ifndef __ASSEMBLY__ +/* + * This output constraint should be used for any inline asm which has a "call" + * instruction. Otherwise the asm may be inserted before the frame pointer + * gets set up by the containing function. If you forget to do this, objtool + * may print a "call without frame pointer save/setup" warning. + */ +register unsigned long current_stack_pointer asm(_ASM_SP); +#define ASM_CALL_CONSTRAINT "+r" (current_stack_pointer) +#endif + #endif /* _ASM_X86_ASM_H */ --- a/arch/x86/include/asm/thread_info.h +++ b/arch/x86/include/asm/thread_info.h @@ -181,9 +181,6 @@ struct thread_info { #ifndef __ASSEMBLY__ -/* how to get the current stack pointer from C */ -register unsigned long current_stack_pointer asm("esp") __used; - /* how to get the thread information struct from C */ static inline struct thread_info *current_thread_info(void) {
[PATCH 3.2 096/104] x86/cpufeatures: Clean up Spectre v2 related CPUID flags
3.2.101-rc1 review patch. If anyone has any objections, please let me know. -- From: David Woodhouse commit 2961298efe1ea1b6fc0d7ee8b76018fa6c0bcef2 upstream. We want to expose the hardware features simply in /proc/cpuinfo as "ibrs", "ibpb" and "stibp". Since AMD has separate CPUID bits for those, use them as the user-visible bits. When the Intel SPEC_CTRL bit is set which indicates both IBRS and IBPB capability, set those (AMD) bits accordingly. Likewise if the Intel STIBP bit is set, set the AMD STIBP that's used for the generic hardware capability. Hide the rest from /proc/cpuinfo by putting "" in the comments. Including RETPOLINE and RETPOLINE_AMD which shouldn't be visible there. There are patches to make the sysfs vulnerabilities information non-readable by non-root, and the same should apply to all information about which mitigations are actually in use. Those *shouldn't* appear in /proc/cpuinfo. The feature bit for whether IBPB is actually used, which is needed for ALTERNATIVEs, is renamed to X86_FEATURE_USE_IBPB. Originally-by: Borislav Petkov Signed-off-by: David Woodhouse Signed-off-by: Thomas Gleixner Cc: a...@linux.intel.com Cc: dave.han...@intel.com Cc: karah...@amazon.de Cc: ar...@linux.intel.com Cc: torva...@linux-foundation.org Cc: pet...@infradead.org Cc: b...@alien8.de Cc: pbonz...@redhat.com Cc: tim.c.c...@linux.intel.com Cc: gre...@linux-foundation.org Link: https://lkml.kernel.org/r/1517070274-12128-2-git-send-email-d...@amazon.co.uk [bwh: For 3.2, just apply the part that hides fake CPU feature bits] Signed-off-by: Ben Hutchings --- --- a/arch/x86/include/asm/cpufeature.h +++ b/arch/x86/include/asm/cpufeature.h @@ -178,10 +178,10 @@ #define X86_FEATURE_PTS(7*32+ 6) /* Intel Package Thermal Status */ #define X86_FEATURE_DTHERM (7*32+ 7) /* Digital Thermal Sensor */ #define X86_FEATURE_INVPCID_SINGLE (7*32+ 8) /* Effectively INVPCID && CR4.PCIDE=1 */ -#define X86_FEATURE_RSB_CTXSW (7*32+9) /* Fill RSB on context switches */ +#define X86_FEATURE_RSB_CTXSW (7*32+9) /* "" Fill RSB on context switches */ -#define X86_FEATURE_RETPOLINE (7*32+29) /* Generic Retpoline mitigation for Spectre variant 2 */ -#define X86_FEATURE_RETPOLINE_AMD (7*32+30) /* AMD Retpoline mitigation for Spectre variant 2 */ +#define X86_FEATURE_RETPOLINE (7*32+29) /* "" Generic Retpoline mitigation for Spectre variant 2 */ +#define X86_FEATURE_RETPOLINE_AMD (7*32+30) /* "" AMD Retpoline mitigation for Spectre variant 2 */ /* Because the ALTERNATIVE scheme is for members of the X86_FEATURE club... */ #define X86_FEATURE_KAISER ( 7*32+31) /* "" CONFIG_PAGE_TABLE_ISOLATION w/o nokaiser */
[PATCH 3.2 094/104] x86/spectre: Simplify spectre_v2 command line parsing
3.2.101-rc1 review patch. If anyone has any objections, please let me know. -- From: KarimAllah Ahmed commit 9005c6834c0ffdfe46afa76656bd9276cca864f6 upstream. [dwmw2: Use ARRAY_SIZE] Signed-off-by: KarimAllah Ahmed Signed-off-by: David Woodhouse Signed-off-by: Thomas Gleixner Cc: pet...@infradead.org Cc: b...@alien8.de Link: https://lkml.kernel.org/r/1517484441-1420-3-git-send-email-d...@amazon.co.uk Signed-off-by: Ben Hutchings --- arch/x86/kernel/cpu/bugs.c | 86 ++ 1 file changed, 56 insertions(+), 30 deletions(-) --- a/arch/x86/kernel/cpu/bugs.c +++ b/arch/x86/kernel/cpu/bugs.c @@ -261,13 +261,13 @@ static inline const char *spectre_v2_mod static void __init spec2_print_if_insecure(const char *reason) { if (boot_cpu_has_bug(X86_BUG_SPECTRE_V2)) - pr_info("%s\n", reason); + pr_info("%s selected on command line.\n", reason); } static void __init spec2_print_if_secure(const char *reason) { if (!boot_cpu_has_bug(X86_BUG_SPECTRE_V2)) - pr_info("%s\n", reason); + pr_info("%s selected on command line.\n", reason); } static inline bool retp_compiler(void) @@ -282,42 +282,68 @@ static inline bool match_option(const ch return len == arglen && !strncmp(arg, opt, len); } +static const struct { + const char *option; + enum spectre_v2_mitigation_cmd cmd; + bool secure; +} mitigation_options[] = { + { "off", SPECTRE_V2_CMD_NONE, false }, + { "on",SPECTRE_V2_CMD_FORCE, true }, + { "retpoline", SPECTRE_V2_CMD_RETPOLINE, false }, + { "retpoline,amd", SPECTRE_V2_CMD_RETPOLINE_AMD, false }, + { "retpoline,generic", SPECTRE_V2_CMD_RETPOLINE_GENERIC, false }, + { "auto", SPECTRE_V2_CMD_AUTO, false }, +}; + static enum spectre_v2_mitigation_cmd __init spectre_v2_parse_cmdline(void) { char arg[20]; - int ret; + int ret, i; + enum spectre_v2_mitigation_cmd cmd = SPECTRE_V2_CMD_AUTO; + + if (cmdline_find_option_bool(boot_command_line, "nospectre_v2")) + return SPECTRE_V2_CMD_NONE; + else { + ret = cmdline_find_option(boot_command_line, "spectre_v2", arg, + sizeof(arg)); + if (ret < 0) + return SPECTRE_V2_CMD_AUTO; - ret = cmdline_find_option(boot_command_line, "spectre_v2", arg, - sizeof(arg)); - if (ret > 0) { - if (match_option(arg, ret, "off")) { - goto disable; - } else if (match_option(arg, ret, "on")) { - spec2_print_if_secure("force enabled on command line."); - return SPECTRE_V2_CMD_FORCE; - } else if (match_option(arg, ret, "retpoline")) { - spec2_print_if_insecure("retpoline selected on command line."); - return SPECTRE_V2_CMD_RETPOLINE; - } else if (match_option(arg, ret, "retpoline,amd")) { - if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD) { - pr_err("retpoline,amd selected but CPU is not AMD. Switching to AUTO select\n"); - return SPECTRE_V2_CMD_AUTO; - } - spec2_print_if_insecure("AMD retpoline selected on command line."); - return SPECTRE_V2_CMD_RETPOLINE_AMD; - } else if (match_option(arg, ret, "retpoline,generic")) { - spec2_print_if_insecure("generic retpoline selected on command line."); - return SPECTRE_V2_CMD_RETPOLINE_GENERIC; - } else if (match_option(arg, ret, "auto")) { + for (i = 0; i < ARRAY_SIZE(mitigation_options); i++) { + if (!match_option(arg, ret, mitigation_options[i].option)) + continue; + cmd = mitigation_options[i].cmd; + break; + } + + if (i >= ARRAY_SIZE(mitigation_options)) { + pr_err("unknown option (%s). Switching to AUTO select\n", + mitigation_options[i].option); return SPECTRE_V2_CMD_AUTO; } } - if (!cmdline_find_option_bool(boot_command_line, "nospectre_v2")) + if ((cmd == SPECTRE_V2_CMD_RETPOLINE || +cmd == SPECTRE_V2_CMD_RETPOLINE_AMD || +cmd == SPECTRE_V2_CMD_RETPOLINE_GENERIC) && + !IS_ENABLED(CONFIG_RETPOLINE)) { + pr_err("%s selected but not compiled in. Switching to AUTO select\n", + mitigation_options[i].option); return SPECTRE_V2_CMD_AUTO; -disable:
[PATCH 3.2 051/104] x86/alternatives: Make optimize_nops() interrupt safe and synced
3.2.101-rc1 review patch. If anyone has any objections, please let me know. -- From: Thomas Gleixner commit 66c117d7fa2ae429911e60d84bf31a90b2b96189 upstream. Richard reported the following crash: [0.036000] BUG: unable to handle kernel paging request at 55501e06 [0.036000] IP: [] common_interrupt+0xb/0x38 [0.036000] Call Trace: [0.036000] [] ? add_nops+0x90/0xa0 [0.036000] [] apply_alternatives+0x274/0x630 Chuck decoded: " 0: 8d 90 90 83 04 24 lea0x24048390(%eax),%edx 6: 80 fc 0fcmp$0xf,%ah 9: a8 0f test $0xf,%al >> b: a0 06 1e 50 55 mov0x55501e06,%al 10: 57 push %edi 11: 56 push %esi Interrupt 0x30 occurred while the alternatives code was replacing the initial 0x90,0x90,0x90 NOPs (from the ASM_CLAC macro) with the optimized version, 0x8d,0x76,0x00. Only the first byte has been replaced so far, and it makes a mess out of the insn decoding." optimize_nops() is buggy in two aspects: - It's not disabling interrupts across the modification - It's lacking a sync_core() call Add both. Fixes: 4fd4b6e5537c 'x86/alternatives: Use optimized NOPs for padding' Reported-and-tested-by: "Richard W.M. Jones" Signed-off-by: Thomas Gleixner Cc: Richard W.M. Jones Cc: Chuck Ebbert Cc: Borislav Petkov Link: http://lkml.kernel.org/r/alpine.DEB.2.11.1509031232340.15006@nanos Signed-off-by: Thomas Gleixner Signed-off-by: Ben Hutchings --- arch/x86/kernel/alternative.c | 5 + 1 file changed, 5 insertions(+) --- a/arch/x86/kernel/alternative.c +++ b/arch/x86/kernel/alternative.c @@ -323,10 +323,15 @@ done: static void __init_or_module optimize_nops(struct alt_instr *a, u8 *instr) { + unsigned long flags; + if (instr[0] != 0x90) return; + local_irq_save(flags); add_nops(instr + (a->instrlen - a->padlen), a->padlen); + sync_core(); + local_irq_restore(flags); DUMP_BYTES(instr, a->instrlen, "%p: [%d:%d) optimized NOPs: ", instr, a->instrlen - a->padlen, a->padlen);
[PATCH 3.2 048/104] sysfs/cpu: Fix typos in vulnerability documentation
3.2.101-rc1 review patch. If anyone has any objections, please let me know. -- From: David Woodhouse commit 9ecccfaa7cb5249bd31bdceb93fcf5bedb8a24d8 upstream. Fixes: 87590ce6e ("sysfs/cpu: Add vulnerability folder") Signed-off-by: David Woodhouse Signed-off-by: Thomas Gleixner Signed-off-by: Ben Hutchings --- Documentation/ABI/testing/sysfs-devices-system-cpu | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/Documentation/ABI/testing/sysfs-devices-system-cpu +++ b/Documentation/ABI/testing/sysfs-devices-system-cpu @@ -206,7 +206,7 @@ What: /sys/devices/system/cpu/vulnerabi /sys/devices/system/cpu/vulnerabilities/meltdown /sys/devices/system/cpu/vulnerabilities/spectre_v1 /sys/devices/system/cpu/vulnerabilities/spectre_v2 -Date: Januar 2018 +Date: January 2018 Contact: Linux kernel mailing list Description: Information about CPU vulnerabilities @@ -216,4 +216,4 @@ Description:Information about CPU vulne "Not affected"CPU is not affected by the vulnerability "Vulnerable" CPU is affected and no mitigation in effect - "Mitigation: $M" CPU is affetcted and mitigation $M is in effect + "Mitigation: $M" CPU is affected and mitigation $M is in effect
[PATCH 3.2 058/104] x86/retpoline: Add initial retpoline support
3.2.101-rc1 review patch. If anyone has any objections, please let me know. -- From: David Woodhouse commit 76b043848fd22dbf7f8bf3a1452f8c70d557b860 upstream. Enable the use of -mindirect-branch=thunk-extern in newer GCC, and provide the corresponding thunks. Provide assembler macros for invoking the thunks in the same way that GCC does, from native and inline assembler. This adds X86_FEATURE_RETPOLINE and sets it by default on all CPUs. In some circumstances, IBRS microcode features may be used instead, and the retpoline can be disabled. On AMD CPUs if lfence is serialising, the retpoline can be dramatically simplified to a simple "lfence; jmp *\reg". A future patch, after it has been verified that lfence really is serialising in all circumstances, can enable this by setting the X86_FEATURE_RETPOLINE_AMD feature bit in addition to X86_FEATURE_RETPOLINE. Do not align the retpoline in the altinstr section, because there is no guarantee that it stays aligned when it's copied over the oldinstr during alternative patching. [ Andi Kleen: Rename the macros, add CONFIG_RETPOLINE option, export thunks] [ tglx: Put actual function CALL/JMP in front of the macros, convert to symbolic labels ] [ dwmw2: Convert back to numeric labels, merge objtool fixes ] Signed-off-by: David Woodhouse Signed-off-by: Thomas Gleixner Acked-by: Arjan van de Ven Acked-by: Ingo Molnar Cc: gno...@lxorguk.ukuu.org.uk Cc: Rik van Riel Cc: Andi Kleen Cc: Josh Poimboeuf Cc: thomas.lenda...@amd.com Cc: Peter Zijlstra Cc: Linus Torvalds Cc: Jiri Kosina Cc: Andy Lutomirski Cc: Dave Hansen Cc: Kees Cook Cc: Tim Chen Cc: Greg Kroah-Hartman Cc: Paul Turner Link: https://lkml.kernel.org/r/1515707194-20531-4-git-send-email-d...@amazon.co.uk [bwh: Backported to 3.2: - Add C source to export the thunk symbols - Drop ANNOTATE_NOSPEC_ALTERNATIVE since we don't have objtool - Use the first available feaure numbers - Adjust filename, context] Signed-off-by: Ben Hutchings --- --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -312,6 +312,19 @@ config X86_BIGSMP ---help--- This option is needed for the systems that have more than 8 CPUs +config RETPOLINE + bool "Avoid speculative indirect branches in kernel" + default y + help + Compile kernel with the retpoline compiler options to guard against + kernel-to-user data leaks by avoiding speculative indirect + branches. Requires a compiler with -mindirect-branch=thunk-extern + support for full protection. The kernel may run slower. + + Without compiler support, at least indirect branches in assembler + code are eliminated. Since this includes the syscall entry path, + it is not entirely pointless. + if X86_32 config X86_EXTENDED_PLATFORM bool "Support for extended (non-PC) x86 platforms" --- a/arch/x86/Makefile +++ b/arch/x86/Makefile @@ -117,6 +117,16 @@ KBUILD_CFLAGS += $(call cc-option,-mno-s KBUILD_CFLAGS += $(mflags-y) KBUILD_AFLAGS += $(mflags-y) +# Avoid indirect branches in kernel to deal with Spectre +ifdef CONFIG_RETPOLINE +RETPOLINE_CFLAGS += $(call cc-option,-mindirect-branch=thunk-extern -mindirect-branch-register) +ifneq ($(RETPOLINE_CFLAGS),) +KBUILD_CFLAGS += $(RETPOLINE_CFLAGS) -DRETPOLINE +else +$(warning CONFIG_RETPOLINE=y, but not supported by the compiler. Toolchain update recommended.) +endif +endif + archscripts: $(Q)$(MAKE) $(build)=arch/x86/tools relocs --- a/arch/x86/include/asm/cpufeature.h +++ b/arch/x86/include/asm/cpufeature.h @@ -179,6 +179,8 @@ #define X86_FEATURE_DTHERM (7*32+ 7) /* Digital Thermal Sensor */ #define X86_FEATURE_INVPCID_SINGLE (7*32+ 8) /* Effectively INVPCID && CR4.PCIDE=1 */ +#define X86_FEATURE_RETPOLINE (7*32+29) /* Generic Retpoline mitigation for Spectre variant 2 */ +#define X86_FEATURE_RETPOLINE_AMD (7*32+30) /* AMD Retpoline mitigation for Spectre variant 2 */ /* Because the ALTERNATIVE scheme is for members of the X86_FEATURE club... */ #define X86_FEATURE_KAISER ( 7*32+31) /* "" CONFIG_PAGE_TABLE_ISOLATION w/o nokaiser */ --- /dev/null +++ b/arch/x86/include/asm/nospec-branch.h @@ -0,0 +1,106 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#ifndef __NOSPEC_BRANCH_H__ +#define __NOSPEC_BRANCH_H__ + +#include +#include +#include + +#ifdef __ASSEMBLY__ + +/* + * These are the bare retpoline primitives for indirect jmp and call. + * Do not use these directly; they only exist to make the ALTERNATIVE + * invocation below less ugly. + */ +.macro RETPOLINE_JMP reg:req + call.Ldo_rop_\@ +.Lspec_trap_\@: + pause + jmp .Lspec_trap_\@ +.Ldo_rop_\@: + mov \reg, (%_ASM_SP) + ret +.endm + +/* + * This is a wrapper around RETPOLINE_JMP so the called function in reg + * returns to the instruction after the macro. + */ +.macro RETPOLINE_CALL reg:req + jmp .Ldo_call_\@ +.Ldo_retpoline_jmp_\@: +
[PATCH 3.2 077/104] module/retpoline: Warn about missing retpoline in module
3.2.101-rc1 review patch. If anyone has any objections, please let me know. -- From: Andi Kleen commit caf7501a1b4ec964190f31f9c3f163de252273b8 upstream. There's a risk that a kernel which has full retpoline mitigations becomes vulnerable when a module gets loaded that hasn't been compiled with the right compiler or the right option. To enable detection of that mismatch at module load time, add a module info string "retpoline" at build time when the module was compiled with retpoline support. This only covers compiled C source, but assembler source or prebuilt object files are not checked. If a retpoline enabled kernel detects a non retpoline protected module at load time, print a warning and report it in the sysfs vulnerability file. [ tglx: Massaged changelog ] Signed-off-by: Andi Kleen Signed-off-by: Thomas Gleixner Cc: David Woodhouse Cc: gre...@linuxfoundation.org Cc: torva...@linux-foundation.org Cc: j...@kernel.org Cc: ar...@linux.intel.com Link: https://lkml.kernel.org/r/20180125235028.31211-1-a...@firstfloor.org Signed-off-by: Ben Hutchings --- arch/x86/kernel/cpu/bugs.c | 17 - include/linux/module.h | 9 + kernel/module.c| 11 +++ scripts/mod/modpost.c | 9 + 4 files changed, 45 insertions(+), 1 deletion(-) --- a/arch/x86/kernel/cpu/bugs.c +++ b/arch/x86/kernel/cpu/bugs.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -235,6 +236,19 @@ static const char *spectre_v2_strings[] #define pr_fmt(fmt) "Spectre V2 mitigation: " fmt static enum spectre_v2_mitigation spectre_v2_enabled = SPECTRE_V2_NONE; +static bool spectre_v2_bad_module; + +#ifdef RETPOLINE +bool retpoline_module_ok(bool has_retpoline) +{ + if (spectre_v2_enabled == SPECTRE_V2_NONE || has_retpoline) + return true; + + pr_err("System may be vunerable to spectre v2\n"); + spectre_v2_bad_module = true; + return false; +} +#endif static void __init spec2_print_if_insecure(const char *reason) { @@ -420,6 +434,7 @@ ssize_t cpu_show_spectre_v2(struct sysde if (!boot_cpu_has_bug(X86_BUG_SPECTRE_V2)) return sprintf(buf, "Not affected\n"); - return sprintf(buf, "%s\n", spectre_v2_strings[spectre_v2_enabled]); + return sprintf(buf, "%s%s\n", spectre_v2_strings[spectre_v2_enabled], + spectre_v2_bad_module ? " - vulnerable module loaded" : ""); } #endif --- a/include/linux/module.h +++ b/include/linux/module.h @@ -661,4 +661,13 @@ static inline void module_bug_finalize(c static inline void module_bug_cleanup(struct module *mod) {} #endif /* CONFIG_GENERIC_BUG */ +#ifdef RETPOLINE +extern bool retpoline_module_ok(bool has_retpoline); +#else +static inline bool retpoline_module_ok(bool has_retpoline) +{ + return true; +} +#endif + #endif /* _LINUX_MODULE_H */ --- a/kernel/module.c +++ b/kernel/module.c @@ -2335,6 +2335,15 @@ static inline void kmemleak_load_module( } #endif +static void check_modinfo_retpoline(struct module *mod, struct load_info *info) +{ + if (retpoline_module_ok(get_modinfo(info, "retpoline"))) + return; + + pr_warn("%s: loading module not compiled with retpoline compiler.\n", + mod->name); +} + /* Sets info->hdr and info->len. */ static int copy_and_check(struct load_info *info, const void __user *umod, unsigned long len, @@ -2495,6 +2504,8 @@ static int check_modinfo(struct module * if (!get_modinfo(info, "intree")) add_taint_module(mod, TAINT_OOT_MODULE); + check_modinfo_retpoline(mod, info); + if (get_modinfo(info, "staging")) { add_taint_module(mod, TAINT_CRAP); printk(KERN_WARNING "%s: module is from the staging directory," --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -1889,6 +1889,14 @@ static void add_intree_flag(struct buffe buf_printf(b, "\nMODULE_INFO(intree, \"Y\");\n"); } +/* Cannot check for assembler */ +static void add_retpoline(struct buffer *b) +{ + buf_printf(b, "\n#ifdef RETPOLINE\n"); + buf_printf(b, "MODULE_INFO(retpoline, \"Y\");\n"); + buf_printf(b, "#endif\n"); +} + static void add_staging_flag(struct buffer *b, const char *name) { static const char *staging_dir = "drivers/staging"; @@ -2210,6 +2218,7 @@ int main(int argc, char **argv) add_header(&buf, mod); add_intree_flag(&buf, !external_module); + add_retpoline(&buf); add_staging_flag(&buf, mod->name); err |= add_versions(&buf, mod); add_depends(&buf, mod, modules);
[PATCH 3.2 104/104] cris: Remove old legacy "-traditional" flag from arch-v10/lib/Makefile
3.2.101-rc1 review patch. If anyone has any objections, please let me know. -- From: Paul Gortmaker commit 7b91747d42a1012e3781dd09fa638d113809e3fd upstream. Most of these have been purged years ago. This one silently lived on until commit 69349c2dc01c489eccaa4c472542c08e370c6d7e "kconfig: fix IS_ENABLED to not require all options to be defined" In the above, we use some macro trickery to create a conditional that is valid in CPP and in C usage. However that trickery doesn't sit well if you have the legacy "-traditional" flag enabled. You'll get: AS arch/cris/arch-v10/lib/checksum.o In file included from :4:0: include/linux/kconfig.h:23:0: error: syntax error in macro parameter list make[2]: *** [arch/cris/arch-v10/lib/checksum.o] Error 1 Everything builds fine w/o "-traditional" so simply drop it from this location as well. Signed-off-by: Paul Gortmaker Signed-off-by: Jesper Nilsson Signed-off-by: Ben Hutchings --- arch/cris/arch-v10/lib/Makefile | 3 --- 1 file changed, 3 deletions(-) --- a/arch/cris/arch-v10/lib/Makefile +++ b/arch/cris/arch-v10/lib/Makefile @@ -2,8 +2,5 @@ # Makefile for Etrax-specific library files.. # - -EXTRA_AFLAGS := -traditional - lib-y = checksum.o checksumcopy.o string.o usercopy.o memset.o csumcpfruser.o
[PATCH 3.2 102/104] x86/uaccess: Use __uaccess_begin_nospec() and uaccess_try_nospec
3.2.101-rc1 review patch. If anyone has any objections, please let me know. -- From: Dan Williams commit 304ec1b050310548db33063e567123fae8fd0301 upstream. Quoting Linus: I do think that it would be a good idea to very expressly document the fact that it's not that the user access itself is unsafe. I do agree that things like "get_user()" want to be protected, but not because of any direct bugs or problems with get_user() and friends, but simply because get_user() is an excellent source of a pointer that is obviously controlled from a potentially attacking user space. So it's a prime candidate for then finding _subsequent_ accesses that can then be used to perturb the cache. __uaccess_begin_nospec() covers __get_user() and copy_from_iter() where the limit check is far away from the user pointer de-reference. In those cases a barrier_nospec() prevents speculation with a potential pointer to privileged memory. uaccess_try_nospec covers get_user_try. Suggested-by: Linus Torvalds Suggested-by: Andi Kleen Signed-off-by: Dan Williams Signed-off-by: Thomas Gleixner Cc: linux-a...@vger.kernel.org Cc: Kees Cook Cc: kernel-harden...@lists.openwall.com Cc: gre...@linuxfoundation.org Cc: Al Viro Cc: a...@linux.intel.com Link: https://lkml.kernel.org/r/151727416953.33451.10508284228526170604.st...@dwillia2-desk3.amr.corp.intel.com [bwh: Backported to 3.2: - There's no SMAP support, so use barrier_nospec() directly instead of __uaccess_begin_nospec() - Convert several more functions to use barrier_nospec(), that are just wrappers in mainline - There's no 'case 8' in __copy_to_user_inatomic() - Adjust context] Signed-off-by: Ben Hutchings --- --- a/arch/x86/include/asm/uaccess.h +++ b/arch/x86/include/asm/uaccess.h @@ -423,6 +423,7 @@ do { \ ({ \ int __gu_err; \ unsigned long __gu_val; \ + barrier_nospec(); \ __get_user_size(__gu_val, (ptr), (size), __gu_err, -EFAULT);\ (x) = (__force __typeof__(*(ptr)))__gu_val; \ __gu_err; \ @@ -529,7 +530,7 @@ struct __large_struct { unsigned long bu * get_user_ex(...); * } get_user_catch(err) */ -#define get_user_try uaccess_try +#define get_user_try uaccess_try_nospec #define get_user_catch(err)uaccess_catch(err) #define get_user_ex(x, ptr)do {\ --- a/arch/x86/include/asm/uaccess_32.h +++ b/arch/x86/include/asm/uaccess_32.h @@ -48,14 +48,17 @@ __copy_to_user_inatomic(void __user *to, switch (n) { case 1: + barrier_nospec(); __put_user_size(*(u8 *)from, (u8 __user *)to, 1, ret, 1); return ret; case 2: + barrier_nospec(); __put_user_size(*(u16 *)from, (u16 __user *)to, 2, ret, 2); return ret; case 4: + barrier_nospec(); __put_user_size(*(u32 *)from, (u32 __user *)to, 4, ret, 4); return ret; @@ -98,12 +101,15 @@ __copy_from_user_inatomic(void *to, cons switch (n) { case 1: + barrier_nospec(); __get_user_size(*(u8 *)to, from, 1, ret, 1); return ret; case 2: + barrier_nospec(); __get_user_size(*(u16 *)to, from, 2, ret, 2); return ret; case 4: + barrier_nospec(); __get_user_size(*(u32 *)to, from, 4, ret, 4); return ret; } @@ -142,12 +148,15 @@ __copy_from_user(void *to, const void __ switch (n) { case 1: + barrier_nospec(); __get_user_size(*(u8 *)to, from, 1, ret, 1); return ret; case 2: + barrier_nospec(); __get_user_size(*(u16 *)to, from, 2, ret, 2); return ret; case 4: + barrier_nospec(); __get_user_size(*(u32 *)to, from, 4, ret, 4); return ret; } @@ -164,12 +173,15 @@ static __always_inline unsigned long __c switch (n) { case 1: + ba
[PATCH 3.2 044/104] x86/cpufeatures: Add X86_BUG_SPECTRE_V[12]
3.2.101-rc1 review patch. If anyone has any objections, please let me know. -- From: David Woodhouse commit 99c6fa2511d8a683e61468be91b83f85452115fa upstream. Add the bug bits for spectre v1/2 and force them unconditionally for all cpus. Signed-off-by: David Woodhouse Signed-off-by: Thomas Gleixner Cc: gno...@lxorguk.ukuu.org.uk Cc: Rik van Riel Cc: Andi Kleen Cc: Peter Zijlstra Cc: Linus Torvalds Cc: Jiri Kosina Cc: Andy Lutomirski Cc: Dave Hansen Cc: Kees Cook Cc: Tim Chen Cc: Greg Kroah-Hartman Cc: Paul Turner Link: https://lkml.kernel.org/r/1515239374-23361-2-git-send-email-d...@amazon.co.uk [bwh: Backported to 3.2: assign the first available bug numbers] Signed-off-by: Ben Hutchings --- arch/x86/include/asm/cpufeature.h | 2 ++ arch/x86/kernel/cpu/common.c | 3 +++ 2 files changed, 5 insertions(+) --- a/arch/x86/include/asm/cpufeature.h +++ b/arch/x86/include/asm/cpufeature.h @@ -215,6 +215,8 @@ #define X86_BUG(x) (NCAPINTS*32 + (x)) #define X86_BUG_CPU_MELTDOWN X86_BUG(0) /* CPU is affected by meltdown attack and needs kernel page table isolation */ +#define X86_BUG_SPECTRE_V1 X86_BUG(1) /* CPU is affected by Spectre variant 1 attack with conditional branches */ +#define X86_BUG_SPECTRE_V2 X86_BUG(2) /* CPU is affected by Spectre variant 2 attack with indirect branches */ #if defined(__KERNEL__) && !defined(__ASSEMBLY__) --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -770,6 +770,9 @@ static void __init early_identify_cpu(st if (c->x86_vendor != X86_VENDOR_AMD) setup_force_cpu_bug(X86_BUG_CPU_MELTDOWN); + + setup_force_cpu_bug(X86_BUG_SPECTRE_V1); + setup_force_cpu_bug(X86_BUG_SPECTRE_V2); } void __init early_cpu_init(void)
[PATCH 3.2 045/104] x86/cpu: Merge bugs.c and bugs_64.c
3.2.101-rc1 review patch. If anyone has any objections, please let me know. -- From: Borislav Petkov commit 62a67e123e058a67db58bc6a14354dd037bafd0a upstream. Should be easier when following boot paths. It probably is a left over from the x86 unification eons ago. No functionality change. Signed-off-by: Borislav Petkov Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Brian Gerst Cc: Denys Vlasenko Cc: H. Peter Anvin Cc: Josh Poimboeuf Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Link: http://lkml.kernel.org/r/20161024173844.23038-3...@alien8.de Signed-off-by: Ingo Molnar [bwh: Backported to 3.2: - Add #ifdef around functions that are not used on x86_64 - Adjust context] Signed-off-by: Ben Hutchings --- --- a/arch/x86/kernel/cpu/Makefile +++ b/arch/x86/kernel/cpu/Makefile @@ -16,9 +16,7 @@ obj-y := intel_cacheinfo.o scattered.o obj-y += proc.o capflags.o powerflags.o common.o obj-y += vmware.o hypervisor.o sched.o mshyperv.o obj-y += rdrand.o - -obj-$(CONFIG_X86_32) += bugs.o -obj-$(CONFIG_X86_64) += bugs_64.o +obj-y += bugs.o obj-$(CONFIG_CPU_SUP_INTEL)+= intel.o obj-$(CONFIG_CPU_SUP_AMD) += amd.o --- a/arch/x86/kernel/cpu/bugs.c +++ b/arch/x86/kernel/cpu/bugs.c @@ -16,6 +16,10 @@ #include #include #include +#include +#include + +#ifdef CONFIG_X86_32 static int __init no_halt(char *s) { @@ -156,6 +160,7 @@ static void __init check_config(void) #endif } +#endif /* CONFIG_X86_32 */ void __init check_bugs(void) { @@ -168,10 +173,13 @@ void __init check_bugs(void) #endif identify_boot_cpu(); -#ifndef CONFIG_SMP - printk(KERN_INFO "CPU: "); - print_cpu_info(&boot_cpu_data); -#endif + + if (!IS_ENABLED(CONFIG_SMP)) { + pr_info("CPU: "); + print_cpu_info(&boot_cpu_data); + } + +#ifdef CONFIG_X86_32 check_config(); check_fpu(); check_hlt(); @@ -179,4 +187,18 @@ void __init check_bugs(void) init_utsname()->machine[1] = '0' + (boot_cpu_data.x86 > 6 ? 6 : boot_cpu_data.x86); alternative_instructions(); +#else /* CONFIG_X86_64 */ + alternative_instructions(); + + /* +* Make sure the first 2MB area is not mapped by huge pages +* There are typically fixed size MTRRs in there and overlapping +* MTRRs into large pages causes slow downs. +* +* Right now we don't do that with gbpages because there seems +* very little benefit for that case. +*/ + if (!direct_gbpages) + set_memory_4k((unsigned long)__va(0), 1); +#endif } --- a/arch/x86/kernel/cpu/bugs_64.c +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (C) 1994 Linus Torvalds - * Copyright (C) 2000 SuSE - */ - -#include -#include -#include -#include -#include -#include -#include - -void __init check_bugs(void) -{ - identify_boot_cpu(); -#if !defined(CONFIG_SMP) - printk(KERN_INFO "CPU: "); - print_cpu_info(&boot_cpu_data); -#endif - alternative_instructions(); - - /* -* Make sure the first 2MB area is not mapped by huge pages -* There are typically fixed size MTRRs in there and overlapping -* MTRRs into large pages causes slow downs. -* -* Right now we don't do that with gbpages because there seems -* very little benefit for that case. -*/ - if (!direct_gbpages) - set_memory_4k((unsigned long)__va(0), 1); -}
[PATCH 3.2 049/104] x86/alternatives: Guard NOPs optimization
3.2.101-rc1 review patch. If anyone has any objections, please let me know. -- From: Borislav Petkov commit 69df353ff305805fc16082d0c5bfa6e20fa8b863 upstream. Take a look at the first instruction byte before optimizing the NOP - there might be something else there already, like the ALTERNATIVE_2() in rdtsc_barrier() which NOPs out on AMD even though we just patched in an MFENCE. This happens because the alternatives sees X86_FEATURE_MFENCE_RDTSC, AMD CPUs set it, we patch in the MFENCE and right afterwards it sees X86_FEATURE_LFENCE_RDTSC which AMD CPUs don't set and we blindly optimize the NOP. Checking whether at least the first byte is 0x90 prevents that. Signed-off-by: Borislav Petkov Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Brian Gerst Cc: Denys Vlasenko Cc: H. Peter Anvin Cc: Linus Torvalds Cc: Thomas Gleixner Link: http://lkml.kernel.org/r/1428181662-18020-1-git-send-email...@alien8.de Signed-off-by: Ingo Molnar Signed-off-by: Ben Hutchings --- arch/x86/kernel/alternative.c | 3 +++ 1 file changed, 3 insertions(+) --- a/arch/x86/kernel/alternative.c +++ b/arch/x86/kernel/alternative.c @@ -323,6 +323,9 @@ done: static void __init_or_module optimize_nops(struct alt_instr *a, u8 *instr) { + if (instr[0] != 0x90) + return; + add_nops(instr + (a->instrlen - a->padlen), a->padlen); DUMP_BYTES(instr, a->instrlen, "%p: [%d:%d) optimized NOPs: ",
[PATCH 3.2 055/104] x86/asm: Make asm/alternative.h safe from assembly
3.2.101-rc1 review patch. If anyone has any objections, please let me know. -- From: Andy Lutomirski commit f005f5d860e0231fe212cfda8c1a3148b99609f4 upstream. asm/alternative.h isn't directly useful from assembly, but it shouldn't break the build. Signed-off-by: Andy Lutomirski Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Brian Gerst Cc: Denys Vlasenko Cc: H. Peter Anvin Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Link: http://lkml.kernel.org/r/e5b693fcef99fe6e80341c9e97a002fb23871e91.1461698311.git.l...@kernel.org Signed-off-by: Ingo Molnar Signed-off-by: Ben Hutchings --- arch/x86/include/asm/alternative.h | 4 1 file changed, 4 insertions(+) --- a/arch/x86/include/asm/alternative.h +++ b/arch/x86/include/asm/alternative.h @@ -1,6 +1,8 @@ #ifndef _ASM_X86_ALTERNATIVE_H #define _ASM_X86_ALTERNATIVE_H +#ifndef __ASSEMBLY__ + #include #include #include @@ -240,4 +242,6 @@ extern void *text_poke(void *addr, const extern void *text_poke_smp(void *addr, const void *opcode, size_t len); extern void text_poke_smp_batch(struct text_poke_param *params, int n); +#endif /* __ASSEMBLY__ */ + #endif /* _ASM_X86_ALTERNATIVE_H */
[PATCH 3.2 098/104] nospec: Move array_index_nospec() parameter checking into separate macro
3.2.101-rc1 review patch. If anyone has any objections, please let me know. -- From: Will Deacon commit 8fa80c503b484ddc1abbd10c7cb2ab81f3824a50 upstream. For architectures providing their own implementation of array_index_mask_nospec() in asm/barrier.h, attempting to use WARN_ONCE() to complain about out-of-range parameters using WARN_ON() results in a mess of mutually-dependent include files. Rather than unpick the dependencies, simply have the core code in nospec.h perform the checking for us. Signed-off-by: Will Deacon Acked-by: Thomas Gleixner Cc: Dan Williams Cc: Linus Torvalds Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/1517840166-15399-1-git-send-email-will.dea...@arm.com Signed-off-by: Ingo Molnar Signed-off-by: Ben Hutchings --- include/linux/nospec.h | 36 +--- 1 file changed, 21 insertions(+), 15 deletions(-) --- a/include/linux/nospec.h +++ b/include/linux/nospec.h @@ -20,20 +20,6 @@ static inline unsigned long array_index_ unsigned long size) { /* -* Warn developers about inappropriate array_index_nospec() usage. -* -* Even if the CPU speculates past the WARN_ONCE branch, the -* sign bit of @index is taken into account when generating the -* mask. -* -* This warning is compiled out when the compiler can infer that -* @index and @size are less than LONG_MAX. -*/ - if (WARN_ONCE(index > LONG_MAX || size > LONG_MAX, - "array_index_nospec() limited to range of [0, LONG_MAX]\n")) - return 0; - - /* * Always calculate and emit the mask even if the compiler * thinks the mask is not needed. The compiler does not take * into account the value of @index under speculation. @@ -44,6 +30,26 @@ static inline unsigned long array_index_ #endif /* + * Warn developers about inappropriate array_index_nospec() usage. + * + * Even if the CPU speculates past the WARN_ONCE branch, the + * sign bit of @index is taken into account when generating the + * mask. + * + * This warning is compiled out when the compiler can infer that + * @index and @size are less than LONG_MAX. + */ +#define array_index_mask_nospec_check(index, size) \ +({ \ + if (WARN_ONCE(index > LONG_MAX || size > LONG_MAX, \ + "array_index_nospec() limited to range of [0, LONG_MAX]\n")) \ + _mask = 0; \ + else \ + _mask = array_index_mask_nospec(index, size); \ + _mask; \ +}) + +/* * array_index_nospec - sanitize an array index after a bounds check * * For a code sequence like: @@ -61,7 +67,7 @@ static inline unsigned long array_index_ ({ \ typeof(index) _i = (index); \ typeof(size) _s = (size); \ - unsigned long _mask = array_index_mask_nospec(_i, _s); \ + unsigned long _mask = array_index_mask_nospec_check(_i, _s);\ \ BUILD_BUG_ON(sizeof(_i) > sizeof(long));\ BUILD_BUG_ON(sizeof(_s) > sizeof(long));\
[PATCH 3.2 042/104] x86/cpu, x86/pti: Do not enable PTI on AMD processors
3.2.101-rc1 review patch. If anyone has any objections, please let me know. -- From: Tom Lendacky commit 694d99d40972f12e59a3696effee8a376b79d7c8 upstream. AMD processors are not subject to the types of attacks that the kernel page table isolation feature protects against. The AMD microarchitecture does not allow memory references, including speculative references, that access higher privileged data when running in a lesser privileged mode when that access would result in a page fault. Disable page table isolation by default on AMD processors by not setting the X86_BUG_CPU_INSECURE feature, which controls whether X86_FEATURE_PTI is set. Signed-off-by: Tom Lendacky Signed-off-by: Thomas Gleixner Reviewed-by: Borislav Petkov Cc: Dave Hansen Cc: Andy Lutomirski Link: https://lkml.kernel.org/r/20171227054354.20369.94587.st...@tlendack-t1.amdoffice.net [bwh: Backported to 3.2: adjust context] Signed-off-by: Ben Hutchings --- arch/x86/kernel/cpu/common.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -768,8 +768,8 @@ static void __init early_identify_cpu(st if (this_cpu->c_bsp_init) this_cpu->c_bsp_init(c); - /* Assume for now that ALL x86 CPUs are insecure */ - setup_force_cpu_bug(X86_BUG_CPU_INSECURE); + if (c->x86_vendor != X86_VENDOR_AMD) + setup_force_cpu_bug(X86_BUG_CPU_INSECURE); } void __init early_cpu_init(void)
[PATCH 3.2 032/104] x86, cpu: Expand cpufeature facility to include cpu bugs
3.2.101-rc1 review patch. If anyone has any objections, please let me know. -- From: Borislav Petkov commit 65fc985b37dc241c4db7cd32adcbc989193fe3c8 upstream. We add another 32-bit vector at the end of the ->x86_capability bitvector which collects bugs present in CPUs. After all, a CPU bug is a kind of a capability, albeit a strange one. Signed-off-by: Borislav Petkov Link: http://lkml.kernel.org/r/1363788448-31325-2-git-send-email...@alien8.de Signed-off-by: H. Peter Anvin [bwh: Backported to 3.2: adjust context] Signed-off-by: Ben Hutchings --- arch/x86/include/asm/cpufeature.h | 13 + arch/x86/include/asm/processor.h | 2 +- arch/x86/kernel/alternative.c | 2 +- arch/x86/kernel/cpu/common.c | 4 4 files changed, 19 insertions(+), 2 deletions(-) --- a/arch/x86/include/asm/cpufeature.h +++ b/arch/x86/include/asm/cpufeature.h @@ -7,6 +7,7 @@ #include #define NCAPINTS 10 /* N 32-bit words worth of info */ +#define NBUGINTS 1 /* N 32-bit bug flags */ /* * Note: If the comment begins with a quoted string, that string is used @@ -208,6 +209,11 @@ #define X86_FEATURE_INVPCID(9*32+10) /* Invalidate Processor Context ID */ #define X86_FEATURE_RTM(9*32+11) /* Restricted Transactional Memory */ +/* + * BUG word(s) + */ +#define X86_BUG(x) (NCAPINTS*32 + (x)) + #if defined(__KERNEL__) && !defined(__ASSEMBLY__) #include @@ -397,6 +403,13 @@ static __always_inline __pure bool __sta #define static_cpu_has(bit) boot_cpu_has(bit) #endif +#define cpu_has_bug(c, bit)cpu_has(c, (bit)) +#define set_cpu_bug(c, bit)set_cpu_cap(c, (bit)) +#define clear_cpu_bug(c, bit) clear_cpu_cap(c, (bit)); + +#define static_cpu_has_bug(bit)static_cpu_has((bit)) +#define boot_cpu_has_bug(bit) cpu_has_bug(&boot_cpu_data, (bit)) + #endif /* defined(__KERNEL__) && !defined(__ASSEMBLY__) */ #endif /* _ASM_X86_CPUFEATURE_H */ --- a/arch/x86/include/asm/processor.h +++ b/arch/x86/include/asm/processor.h @@ -86,7 +86,7 @@ struct cpuinfo_x86 { __u32 extended_cpuid_level; /* Maximum supported CPUID level, -1=no CPUID: */ int cpuid_level; - __u32 x86_capability[NCAPINTS]; + __u32 x86_capability[NCAPINTS + NBUGINTS]; charx86_vendor_id[16]; charx86_model_id[64]; /* in KB - valid for CPUS which support this call: */ --- a/arch/x86/kernel/alternative.c +++ b/arch/x86/kernel/alternative.c @@ -359,7 +359,7 @@ void __init_or_module apply_alternatives instr = (u8 *)&a->instr_offset + a->instr_offset; replacement = (u8 *)&a->repl_offset + a->repl_offset; BUG_ON(a->instrlen > sizeof(insnbuf)); - BUG_ON(a->cpuid >= NCAPINTS*32); + BUG_ON(a->cpuid >= (NCAPINTS + NBUGINTS) * 32); if (!boot_cpu_has(a->cpuid)) { if (a->padlen > 1) optimize_nops(a, instr); --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -954,6 +954,10 @@ static void __cpuinit identify_cpu(struc /* AND the already accumulated flags with these */ for (i = 0; i < NCAPINTS; i++) boot_cpu_data.x86_capability[i] &= c->x86_capability[i]; + + /* OR, i.e. replicate the bug flags */ + for (i = NCAPINTS; i < NCAPINTS + NBUGINTS; i++) + c->x86_capability[i] |= boot_cpu_data.x86_capability[i]; } /* Init Machine Check Exception if available. */