[PATCH v4 1/2] dt-bindings: serial: Add rx-tx-swap to stm32-usart
Add new rx-tx-swap property to allow for RX & TX pin swapping. Signed-off-by: Martin Devera --- .../devicetree/bindings/serial/st,stm32-uart.yaml | 32 +++--- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/Documentation/devicetree/bindings/serial/st,stm32-uart.yaml b/Documentation/devicetree/bindings/serial/st,stm32-uart.yaml index 8631678283f9..6eab2debebb5 100644 --- a/Documentation/devicetree/bindings/serial/st,stm32-uart.yaml +++ b/Documentation/devicetree/bindings/serial/st,stm32-uart.yaml @@ -9,9 +9,6 @@ maintainers: title: STMicroelectronics STM32 USART bindings -allOf: - - $ref: rs485.yaml - properties: compatible: enum: @@ -40,6 +37,10 @@ properties: uart-has-rtscts: true + rx-tx-swap: +type: boolean +maxItems: 1 + dmas: minItems: 1 maxItems: 2 @@ -66,13 +67,24 @@ properties: linux,rs485-enabled-at-boot-time: true rs485-rx-during-tx: true -if: - required: -- st,hw-flow-ctrl -then: - properties: -cts-gpios: false -rts-gpios: false +allOf: + - $ref: rs485.yaml + - if: + required: +- st,hw-flow-ctrl +then: + properties: +cts-gpios: false +rts-gpios: false + - if: + required: +- rx-tx-swap +then: + properties: +compatible: + enum: +- st,stm32f7-uart +- st,stm32h7-uart required: - compatible -- 2.11.0
Re: [PATCH 5.10 000/658] 5.10.20-rc3 review
On Tue, Mar 02, 2021 at 10:44:15AM -0800, Guenter Roeck wrote: > On 3/2/21 4:38 AM, Greg Kroah-Hartman wrote: > > This is the start of the stable review cycle for the 5.10.20 release. > > There are 658 patches in this series, all will be posted as a response > > to this one. If anyone has any issues with these being applied, please > > let me know. > > > > Responses should be made by Thu, 04 Mar 2021 12:32:41 +. > > Anything received after that time might be too late. > > > > Building arm:allmodconfig ... failed > -- > Error log: > drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c: In function 'mtk_aal_config': > drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c:183:54: error: 'struct > mtk_ddp_comp' has no member named 'dev' > 183 | struct mtk_ddp_comp_dev *priv = dev_get_drvdata(comp->dev); > | ^~ > drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c:185:44: error: dereferencing > pointer to incomplete type 'struct mtk_ddp_comp_dev' > 185 | mtk_ddp_write(cmdq_pkt, w << 16 | h, &priv->cmdq_reg, priv->regs, > DISP_AAL_SIZE); > |^~ > drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c:185:2: error: too many arguments > to function 'mtk_ddp_write' > 185 | mtk_ddp_write(cmdq_pkt, w << 16 | h, &priv->cmdq_reg, priv->regs, > DISP_AAL_SIZE); > | ^ > drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c:89:6: note: declared here >89 | void mtk_ddp_write(struct cmdq_pkt *cmdq_pkt, unsigned int value, > | ^ > make[5]: *** [drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.o] Error 1 > make[4]: *** [drivers/gpu/drm/mediatek] Error 2 > > --- > Building arm64:allmodconfig ... failed > -- > Error log: > drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c: In function 'mtk_aal_config': > drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c:183:54: error: 'struct > mtk_ddp_comp' has no member named 'dev' > 183 | struct mtk_ddp_comp_dev *priv = dev_get_drvdata(comp->dev); > | ^~ > drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c:185:44: error: dereferencing > pointer to incomplete type 'struct mtk_ddp_comp_dev' > 185 | mtk_ddp_write(cmdq_pkt, w << 16 | h, &priv->cmdq_reg, priv->regs, > DISP_AAL_SIZE); > |^~ > drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c:185:2: error: too many arguments > to function 'mtk_ddp_write' > 185 | mtk_ddp_write(cmdq_pkt, w << 16 | h, &priv->cmdq_reg, priv->regs, > DISP_AAL_SIZE); > | ^ > drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c:89:6: note: declared here >89 | void mtk_ddp_write(struct cmdq_pkt *cmdq_pkt, unsigned int value, > | ^ > make[5]: *** [drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.o] Error 1 > > > The same problem also affects v5.11.y. > > Am I missing something here ? Why do I see that problem ? It seems to be very > basic. You aren't the only one, I got an off-list response that this was seen as well. Let me dig into it... greg k-h
[PATCH v4 2/2] tty/serial: Add rx-tx-swap OF option to stm32-usart
STM32 F7/H7 usarts supports RX & TX pin swapping. Add option to turn it on. Tested on STM32MP157. Signed-off-by: Martin Devera --- drivers/tty/serial/stm32-usart.c | 11 ++- drivers/tty/serial/stm32-usart.h | 4 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/tty/serial/stm32-usart.c b/drivers/tty/serial/stm32-usart.c index b3675cf25a69..d390f7da1441 100644 --- a/drivers/tty/serial/stm32-usart.c +++ b/drivers/tty/serial/stm32-usart.c @@ -644,6 +644,12 @@ static int stm32_usart_startup(struct uart_port *port) if (ret) return ret; + if (stm32_port->swap) { + val = readl_relaxed(port->membase + ofs->cr2); + val |= USART_CR2_SWAP; + writel_relaxed(val, port->membase + ofs->cr2); + } + /* RX FIFO Flush */ if (ofs->rqr != UNDEF_REG) stm32_usart_set_bits(port, ofs->rqr, USART_RQR_RXFRQ); @@ -758,7 +764,7 @@ static void stm32_usart_set_termios(struct uart_port *port, cr1 = USART_CR1_TE | USART_CR1_RE; if (stm32_port->fifoen) cr1 |= USART_CR1_FIFOEN; - cr2 = 0; + cr2 = stm32_port->swap ? USART_CR2_SWAP : 0; cr3 = readl_relaxed(port->membase + ofs->cr3); cr3 &= USART_CR3_TXFTIE | USART_CR3_RXFTCFG_MASK | USART_CR3_RXFTIE | USART_CR3_TXFTCFG_MASK; @@ -1006,6 +1012,9 @@ static int stm32_usart_init_port(struct stm32_port *stm32port, return stm32port->wakeirq ? : -ENODEV; } + stm32port->swap = stm32port->info->cfg.has_swap && + of_property_read_bool(pdev->dev.of_node, "rx-tx-swap"); + stm32port->fifoen = stm32port->info->cfg.has_fifo; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); diff --git a/drivers/tty/serial/stm32-usart.h b/drivers/tty/serial/stm32-usart.h index cb4f327c46db..a85391e71e8e 100644 --- a/drivers/tty/serial/stm32-usart.h +++ b/drivers/tty/serial/stm32-usart.h @@ -25,6 +25,7 @@ struct stm32_usart_offsets { struct stm32_usart_config { u8 uart_enable_bit; /* USART_CR1_UE */ bool has_7bits_data; + bool has_swap; bool has_wakeup; bool has_fifo; int fifosize; @@ -76,6 +77,7 @@ struct stm32_usart_info stm32f7_info = { .cfg = { .uart_enable_bit = 0, .has_7bits_data = true, + .has_swap = true, .fifosize = 1, } }; @@ -97,6 +99,7 @@ struct stm32_usart_info stm32h7_info = { .cfg = { .uart_enable_bit = 0, .has_7bits_data = true, + .has_swap = true, .has_wakeup = true, .has_fifo = true, .fifosize = 16, @@ -271,6 +274,7 @@ struct stm32_port { int last_res; bool tx_dma_busy;/* dma tx busy */ bool hw_flow_control; + bool swap; /* swap RX & TX pins */ bool fifoen; int wakeirq; int rdr_mask; /* receive data register mask */ -- 2.11.0
Re: [PATCH] MIPS: BMIPS: Reserve exception base to prevent corruption
On Mon, Mar 01, 2021 at 08:19:38PM -0800, Florian Fainelli wrote: > BMIPS is one of the few platforms that do change the exception base. > After commit 2dcb39645441 ("memblock: do not start bottom-up allocations > with kernel_end") we started seeing BMIPS boards fail to boot with the > built-in FDT being corrupted. > > Before the cited commit, early allocations would be in the [kernel_end, > RAM_END] range, but after commit they would be within [RAM_START + > PAGE_SIZE, RAM_END]. > > The custom exception base handler that is installed by > bmips_ebase_setup() done for BMIPS5000 CPUs ends-up trampling on the > memory region allocated by unflatten_and_copy_device_tree() thus > corrupting the FDT used by the kernel. > > To fix this, we need to perform an early reservation of the custom > exception that is going to be installed and this needs to happen at > plat_mem_setup() time to ensure that unflatten_and_copy_device_tree() > finds a space that is suitable, away from reserved memory. > > Huge thanks to Serget for analysing and proposing a solution to this > issue. > > Fixes: Fixes: 2dcb39645441 ("memblock: do not start bottom-up allocations > with kernel_end") > Debugged-by: Serge Semin > Reported-by: Kamal Dasu > Signed-off-by: Florian Fainelli Acked-by: Roman Gushchin Thank you! > --- > Thomas, > > This is intended as a stop-gap solution for 5.12-rc1 and to be picked up > by the stable team for 5.11. We should find a safer way to avoid these > problems for 5.13 maybe. > > arch/mips/bmips/setup.c | 22 ++ > arch/mips/include/asm/traps.h | 2 ++ > 2 files changed, 24 insertions(+) > > diff --git a/arch/mips/bmips/setup.c b/arch/mips/bmips/setup.c > index 31bcfa4e08b9..0088bd45b892 100644 > --- a/arch/mips/bmips/setup.c > +++ b/arch/mips/bmips/setup.c > @@ -149,6 +149,26 @@ void __init plat_time_init(void) > mips_hpt_frequency = freq; > } > > +static void __init bmips_ebase_reserve(void) > +{ > + phys_addr_t base, size = VECTORSPACING * 64; > + > + switch (current_cpu_type()) { > + default: > + case CPU_BMIPS4350: > + return; > + case CPU_BMIPS3300: > + case CPU_BMIPS4380: > + base = 0x0400; > + break; > + case CPU_BMIPS5000: > + base = 0x1000; > + break; > + } > + > + memblock_reserve(base, size); > +} > + > void __init plat_mem_setup(void) > { > void *dtb; > @@ -169,6 +189,8 @@ void __init plat_mem_setup(void) > > __dt_setup_arch(dtb); > > + bmips_ebase_reserve(); > + > for (q = bmips_quirk_list; q->quirk_fn; q++) { > if (of_flat_dt_is_compatible(of_get_flat_dt_root(), >q->compatible)) { > diff --git a/arch/mips/include/asm/traps.h b/arch/mips/include/asm/traps.h > index 6aa8f126a43d..0ba6bb7f9618 100644 > --- a/arch/mips/include/asm/traps.h > +++ b/arch/mips/include/asm/traps.h > @@ -14,6 +14,8 @@ > #define MIPS_BE_FIXUP1 /* return to the fixup code */ > #define MIPS_BE_FATAL2 /* treat as an unrecoverable > error */ > > +#define VECTORSPACING 0x100 /* for EI/VI mode */ > + > extern void (*board_be_init)(void); > extern int (*board_be_handler)(struct pt_regs *regs, int is_fixup); > > -- > 2.25.1 >
Re: [PATCH 5/5] net: page_pool: use alloc_pages_bulk in refill code path
On Mon, Mar 01, 2021 at 04:12:00PM +, Mel Gorman wrote: > From: Jesper Dangaard Brouer > > There are cases where the page_pool need to refill with pages from the > page allocator. Some workloads cause the page_pool to release pages > instead of recycling these pages. > > For these workload it can improve performance to bulk alloc pages from > the page-allocator to refill the alloc cache. > > For XDP-redirect workload with 100G mlx5 driver (that use page_pool) > redirecting xdp_frame packets into a veth, that does XDP_PASS to create > an SKB from the xdp_frame, which then cannot return the page to the > page_pool. In this case, we saw[1] an improvement of 18.8% from using > the alloc_pages_bulk API (3,677,958 pps -> 4,368,926 pps). > > [1] > https://github.com/xdp-project/xdp-project/blob/master/areas/mem/page_pool06_alloc_pages_bulk.org > > Signed-off-by: Jesper Dangaard Brouer > Signed-off-by: Mel Gorman > --- > net/core/page_pool.c | 63 > 1 file changed, 40 insertions(+), 23 deletions(-) > > diff --git a/net/core/page_pool.c b/net/core/page_pool.c > index a26f2ceb6a87..567680bd91c4 100644 > --- a/net/core/page_pool.c > +++ b/net/core/page_pool.c > @@ -208,44 +208,61 @@ noinline > static struct page *__page_pool_alloc_pages_slow(struct page_pool *pool, >gfp_t _gfp) > { > + const int bulk = PP_ALLOC_CACHE_REFILL; > + struct page *page, *next, *first_page; > unsigned int pp_flags = pool->p.flags; > - struct page *page; > + unsigned int pp_order = pool->p.order; > + int pp_nid = pool->p.nid; > + LIST_HEAD(page_list); > gfp_t gfp = _gfp; > > - /* We could always set __GFP_COMP, and avoid this branch, as > - * prep_new_page() can handle order-0 with __GFP_COMP. > - */ > - if (pool->p.order) > + /* Don't support bulk alloc for high-order pages */ > + if (unlikely(pp_order)) { > gfp |= __GFP_COMP; > + first_page = alloc_pages_node(pp_nid, gfp, pp_order); > + if (unlikely(!first_page)) > + return NULL; > + goto out; > + } > > - /* FUTURE development: > - * > - * Current slow-path essentially falls back to single page > - * allocations, which doesn't improve performance. This code > - * need bulk allocation support from the page allocator code. > - */ > - > - /* Cache was empty, do real allocation */ > -#ifdef CONFIG_NUMA > - page = alloc_pages_node(pool->p.nid, gfp, pool->p.order); > -#else > - page = alloc_pages(gfp, pool->p.order); > -#endif > - if (!page) > + if (unlikely(!__alloc_pages_bulk_nodemask(gfp, pp_nid, NULL, > + bulk, &page_list))) > return NULL; > > + /* First page is extracted and returned to caller */ > + first_page = list_first_entry(&page_list, struct page, lru); > + list_del(&first_page->lru); > + > + /* Remaining pages store in alloc.cache */ > + list_for_each_entry_safe(page, next, &page_list, lru) { > + list_del(&page->lru); > + if (pp_flags & PP_FLAG_DMA_MAP && > + unlikely(!page_pool_dma_map(pool, page))) { > + put_page(page); > + continue; > + } > + if (likely(pool->alloc.count < PP_ALLOC_CACHE_SIZE)) { > + pool->alloc.cache[pool->alloc.count++] = page; > + pool->pages_state_hold_cnt++; > + trace_page_pool_state_hold(pool, page, > +pool->pages_state_hold_cnt); > + } else { > + put_page(page); > + } > + } > +out: > if (pp_flags & PP_FLAG_DMA_MAP && > - unlikely(!page_pool_dma_map(pool, page))) { > - put_page(page); > + unlikely(!page_pool_dma_map(pool, first_page))) { > + put_page(first_page); > return NULL; > } > > /* Track how many pages are held 'in-flight' */ > pool->pages_state_hold_cnt++; > - trace_page_pool_state_hold(pool, page, pool->pages_state_hold_cnt); > + trace_page_pool_state_hold(pool, first_page, > pool->pages_state_hold_cnt); > > /* When page just alloc'ed is should/must have refcnt 1. */ > - return page; > + return first_page; > } > > /* For using page_pool replace: alloc_pages() API calls, but provide > -- > 2.26.2 > Reviewed-by: Ilias Apalodimas
Re: [PATCH mtd/next 2/8] mtd: ftl: Use module_mtd_blktrans to register driver
On Sat, 2021-02-13 at 16:45:54 UTC, Dejin Zheng wrote: > Removing some boilerplate by using module_mtd_blktrans instead of calling > register and unregister in the otherwise empty init/exit functions. > > Signed-off-by: Dejin Zheng Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/next, thanks. Miquel
Re: [PATCH v3 3/6] can: c_can: fix control interface used by c_can_do_tx
On Sun, 28 Feb 2021 11:38:52 +0100, Dario Binacchi wrote: > According to commit 640916db2bf7 ("can: c_can: Make it SMP safe") let RX use > IF1 (i.e. IF_RX) and TX use IF2 (i.e. IF_TX). > > Signed-off-by: Dario Binacchi > --- > > (no changes since v1) > > drivers/net/can/c_can/c_can.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/net/can/c_can/c_can.c b/drivers/net/can/c_can/c_can.c > index dbcc1c1c92d6..69526c3a671c 100644 > --- a/drivers/net/can/c_can/c_can.c > +++ b/drivers/net/can/c_can/c_can.c > @@ -732,7 +732,7 @@ static void c_can_do_tx(struct net_device *dev) > idx--; > pend &= ~(1 << idx); > obj = idx + C_CAN_MSG_OBJ_TX_FIRST; > - c_can_inval_tx_object(dev, IF_RX, obj); > + c_can_inval_tx_object(dev, IF_TX, obj); Right. I had a similar effort last year to increase the reception throughput, but I ended with some sporadic strange tx echo problems. This fix may have fixed my problem as wel. > can_get_echo_skb(dev, idx, NULL); > bytes += priv->dlc[idx]; > pkts++; > -- > 2.17.1 >
Re: [PATCH v3 5/6] can: c_can: prepare to up the message objects number
On Sun, 28 Feb 2021 11:38:54 +0100, Dario Binacchi wrote: > Date: Sun, 28 Feb 2021 11:38:54 +0100 > From: Dario Binacchi > To: linux-kernel@vger.kernel.org > Cc: Federico Vaga , Alexander Stein > , Dario Binacchi > , "David S. Miller" , Jakub > Kicinski , Marc Kleine-Budde , Oliver > Hartkopp , Vincent Mailhol > , Wolfgang Grandegger , > YueHaibing , Zhang Qilong > , linux-...@vger.kernel.org, > net...@vger.kernel.org > Subject: [PATCH v3 5/6] can: c_can: prepare to up the message objects number > X-Mailer: git-send-email 2.17.1 > > As pointed by commit c0a9f4d396c9 ("can: c_can: Reduce register access") > the "driver casts the 16 message objects in stone, which is completely > braindead as contemporary hardware has up to 128 message objects". > > The patch prepares the module to extend the number of message objects > beyond the 32 currently managed. This was achieved by transforming the > constants used to manage RX/TX messages into variables without changing > the driver policy. > > Signed-off-by: Dario Binacchi > Reported-by: kernel test robot > > --- > > Changes in v3: > - Use unsigned int instead of int as type of the msg_obj_* fields > in the c_can_priv structure. > - Replace (u64)1 with 1UL in msg_obj_rx_mask setting. > > Changes in v2: > - Fix compiling error reported by kernel test robot. > - Add Reported-by tag. > - Pass larger size to alloc_candev() routine to avoid an additional > memory allocation/deallocation. > > drivers/net/can/c_can/c_can.c | 50 -- > drivers/net/can/c_can/c_can.h | 23 ++-- > drivers/net/can/c_can/c_can_pci.c | 2 +- > drivers/net/can/c_can/c_can_platform.c | 2 +- > 4 files changed, 43 insertions(+), 34 deletions(-) > > diff --git a/drivers/net/can/c_can/c_can.c b/drivers/net/can/c_can/c_can.c > index 7081cfaf62e2..ede6f4d62095 100644 > --- a/drivers/net/can/c_can/c_can.c > +++ b/drivers/net/can/c_can/c_can.c > @@ -173,9 +173,6 @@ > /* Wait for ~1 sec for INIT bit */ > #define INIT_WAIT_MS 1000 > > -/* napi related */ > -#define C_CAN_NAPI_WEIGHTC_CAN_MSG_OBJ_RX_NUM > - > /* c_can lec values */ > enum c_can_lec_type { > LEC_NO_ERROR = 0, > @@ -325,7 +322,7 @@ static void c_can_setup_tx_object(struct net_device *dev, > int iface, >* first, i.e. clear the MSGVAL flag in the arbiter. >*/ > if (rtr != (bool)test_bit(idx, &priv->tx_dir)) { > - u32 obj = idx + C_CAN_MSG_OBJ_TX_FIRST; > + u32 obj = idx + priv->msg_obj_tx_first; > > c_can_inval_msg_object(dev, iface, obj); > change_bit(idx, &priv->tx_dir); > @@ -463,10 +460,10 @@ static netdev_tx_t c_can_start_xmit(struct sk_buff *skb, >* prioritized. The lowest buffer number wins. >*/ > idx = fls(atomic_read(&priv->tx_active)); > - obj = idx + C_CAN_MSG_OBJ_TX_FIRST; > + obj = idx + priv->msg_obj_tx_first; > > /* If this is the last buffer, stop the xmit queue */ > - if (idx == C_CAN_MSG_OBJ_TX_NUM - 1) > + if (idx == priv->msg_obj_tx_num - 1) > netif_stop_queue(dev); > /* >* Store the message in the interface so we can call > @@ -549,17 +546,18 @@ static int c_can_set_bittiming(struct net_device *dev) > */ > static void c_can_configure_msg_objects(struct net_device *dev) > { > + struct c_can_priv *priv = netdev_priv(dev); > int i; > > /* first invalidate all message objects */ > - for (i = C_CAN_MSG_OBJ_RX_FIRST; i <= C_CAN_NO_OF_OBJECTS; i++) > + for (i = priv->msg_obj_rx_first; i <= priv->msg_obj_num; i++) > c_can_inval_msg_object(dev, IF_RX, i); > > /* setup receive message objects */ > - for (i = C_CAN_MSG_OBJ_RX_FIRST; i < C_CAN_MSG_OBJ_RX_LAST; i++) > + for (i = priv->msg_obj_rx_first; i < priv->msg_obj_rx_last; i++) > c_can_setup_receive_object(dev, IF_RX, i, 0, 0, IF_MCONT_RCV); > > - c_can_setup_receive_object(dev, IF_RX, C_CAN_MSG_OBJ_RX_LAST, 0, 0, > + c_can_setup_receive_object(dev, IF_RX, priv->msg_obj_rx_last, 0, 0, > IF_MCONT_RCV_EOB); > } > > @@ -730,7 +728,7 @@ static void c_can_do_tx(struct net_device *dev) > while ((idx = ffs(pend))) { > idx--; > pend &= ~(1 << idx); > - obj = idx + C_CAN_MSG_OBJ_TX_FIRST; > + obj = idx + priv->msg_obj_tx_first; > c_can_inval_tx_object(dev, IF_TX, obj); > can_get_echo_skb(dev, idx, NULL); > bytes += priv->dlc[idx]; > @@ -740,7 +738,7 @@ static void c_can_do_tx(struct net_device *dev) > /* Clear the bits in the tx_active mask */ > atomic_sub(clr, &priv->tx_active); > > - if (clr & (1 << (C_CAN_MSG_OBJ_TX_NUM - 1))) > + if (clr & (1 << (priv->msg_obj_tx_num - 1))) > netif_wake_queue(dev); > > if (pkts) { > @@ -755,11 +753,11 @@ static void c_can_do_tx(struct net_de
Re: [PATCH v3] drivers: hv: Fix whitespace errors
On Fri, Feb 19, 2021 at 05:30:36PM +, Michael Kelley wrote: > From: Vasanth Sent: Friday, February 19, 2021 9:13 AM > > To: KY Srinivasan > > Cc: Haiyang Zhang ; Stephen Hemminger > > ; wei@kernel.org; linux-hyp...@vger.kernel.org; > > linux- > > ker...@vger.kernel.org; Vasanth > > Subject: [PATCH v3] drivers: hv: Fix whitespace errors > > > > Fixed checkpatch warning and errors on hv driver. > > > > Signed-off-by: Vasanth Vasanth, normally people put their full name in the SoB. Do you want to do that too? There is no need to resend. Just let me know what you think. > > --- > > Reviewed-by: Michael Kelley Thanks Michael. I will pick up this patch within this week. Wei.
Re: [PATCH v3 2/2] tty/serial: Add rx-tx-swap OF option to stm32-usart
On 3/2/21 6:44 PM, Fabrice Gasnier wrote: On 3/2/21 2:15 PM, Martin Devera wrote: STM32 F7/H7 usarts supports RX & TX pin swapping. Add option to turn it on. Tested on STM32MP157. Signed-off-by: Martin Devera --- drivers/tty/serial/stm32-usart.c | 11 ++- drivers/tty/serial/stm32-usart.h | 5 + 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/drivers/tty/serial/stm32-usart.c b/drivers/tty/serial/stm32-usart.c index b3675cf25a69..d390f7da1441 100644 --- a/drivers/tty/serial/stm32-usart.c +++ b/drivers/tty/serial/stm32-usart.c @@ -644,6 +644,12 @@ static int stm32_usart_startup(struct uart_port *port) if (ret) return ret; + if (stm32_port->swap) { + val = readl_relaxed(port->membase + ofs->cr2); + val |= USART_CR2_SWAP; + writel_relaxed(val, port->membase + ofs->cr2); + } + /* RX FIFO Flush */ if (ofs->rqr != UNDEF_REG) stm32_usart_set_bits(port, ofs->rqr, USART_RQR_RXFRQ); @@ -758,7 +764,7 @@ static void stm32_usart_set_termios(struct uart_port *port, cr1 = USART_CR1_TE | USART_CR1_RE; if (stm32_port->fifoen) cr1 |= USART_CR1_FIFOEN; - cr2 = 0; + cr2 = stm32_port->swap ? USART_CR2_SWAP : 0; cr3 = readl_relaxed(port->membase + ofs->cr3); cr3 &= USART_CR3_TXFTIE | USART_CR3_RXFTCFG_MASK | USART_CR3_RXFTIE | USART_CR3_TXFTCFG_MASK; @@ -1006,6 +1012,9 @@ static int stm32_usart_init_port(struct stm32_port *stm32port, return stm32port->wakeirq ? : -ENODEV; } + stm32port->swap = stm32port->info->cfg.has_swap && + of_property_read_bool(pdev->dev.of_node, "rx-tx-swap"); + stm32port->fifoen = stm32port->info->cfg.has_fifo; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); diff --git a/drivers/tty/serial/stm32-usart.h b/drivers/tty/serial/stm32-usart.h index cb4f327c46db..bd18dd1c1bcd 100644 --- a/drivers/tty/serial/stm32-usart.h +++ b/drivers/tty/serial/stm32-usart.h @@ -25,6 +25,7 @@ struct stm32_usart_offsets { struct stm32_usart_config { u8 uart_enable_bit; /* USART_CR1_UE */ bool has_7bits_data; + bool has_swap; bool has_wakeup; bool has_fifo; int fifosize; @@ -55,6 +56,7 @@ struct stm32_usart_info stm32f4_info = { .cfg = { .uart_enable_bit = 13, .has_7bits_data = false, + .has_swap = false, Hi Martin, Only one minor comment from me here. No need to add a false (zero) initialization in this struct. I'm not sure why this is the case for the has_7bits_data here... With that fixed, you can add my: Acked-by: Fabrice Gasnier The has_7bits_data was what made me a bit unsure. Ok fixed now. Thank you for your review. Martin
Re: [PATCH 40/44] tty: hvc, drop unneeded forward declarations
On 3/1/21 10:22 PM, Jiri Slaby wrote: > Forward declarations make the code larger and rewrites harder. Harder as > they are often omitted from global changes. Remove forward declarations > which are not really needed, i.e. the definition of the function is > before its first use. > > Signed-off-by: Jiri Slaby > Cc: linuxppc-...@lists.ozlabs.org Reviewed-by: Tyrel Datwyler > --- > drivers/tty/hvc/hvcs.c | 25 - > 1 file changed, 25 deletions(-) > > diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c > index c90848919644..0b89d878a108 100644 > --- a/drivers/tty/hvc/hvcs.c > +++ b/drivers/tty/hvc/hvcs.c > @@ -290,36 +290,11 @@ static LIST_HEAD(hvcs_structs); > static DEFINE_SPINLOCK(hvcs_structs_lock); > static DEFINE_MUTEX(hvcs_init_mutex); > > -static void hvcs_unthrottle(struct tty_struct *tty); > -static void hvcs_throttle(struct tty_struct *tty); > -static irqreturn_t hvcs_handle_interrupt(int irq, void *dev_instance); > - > -static int hvcs_write(struct tty_struct *tty, > - const unsigned char *buf, int count); > -static int hvcs_write_room(struct tty_struct *tty); > -static int hvcs_chars_in_buffer(struct tty_struct *tty); > - > -static int hvcs_has_pi(struct hvcs_struct *hvcsd); > -static void hvcs_set_pi(struct hvcs_partner_info *pi, > - struct hvcs_struct *hvcsd); > static int hvcs_get_pi(struct hvcs_struct *hvcsd); > static int hvcs_rescan_devices_list(void); > > -static int hvcs_partner_connect(struct hvcs_struct *hvcsd); > static void hvcs_partner_free(struct hvcs_struct *hvcsd); > > -static int hvcs_enable_device(struct hvcs_struct *hvcsd, > - uint32_t unit_address, unsigned int irq, struct vio_dev *dev); > - > -static int hvcs_open(struct tty_struct *tty, struct file *filp); > -static void hvcs_close(struct tty_struct *tty, struct file *filp); > -static void hvcs_hangup(struct tty_struct * tty); > - > -static int hvcs_probe(struct vio_dev *dev, > - const struct vio_device_id *id); > -static int hvcs_remove(struct vio_dev *dev); > -static int __init hvcs_module_init(void); > -static void __exit hvcs_module_exit(void); > static int hvcs_initialize(void); > > #define HVCS_SCHED_READ 0x0001 >
Re: KASAN: use-after-free Read in cipso_v4_genopt
On Tue, Mar 2, 2021 at 5:10 PM Paul Moore wrote: > > On Tue, Mar 2, 2021 at 6:03 AM Dmitry Vyukov wrote: > > > > ... > > > Besides these 2 crashes, we've also seen one on a 4.19 based kernel, see > > below. > > Based on the reports with mismatching stacks, it looks like > > cipso_v4_genopt is doing some kind of wild pointer access (uninit > > pointer?). > > Hmm, interesting. Looking quickly at the stack dump, it appears that > the problem occurs (at least in the recent kernel) when accessing the > cipso_v4_doi.tags[] array which is embedded in the cipso_v4_doi > struct. Based on the code in cipso_v4_genopt() it doesn't appear that > we are shooting past the end of the array/struct and the cipso_v4_doi > struct appears to be refcounted correctly in cipso_v4_doi_getdef() and > cipso_v4_doi_putdef(). I'll look at it some more today to see if > something jumps out at me, but obviously a reproducer would be very > helpful if you are able to find one. > > It's also worth adding that this code really hasn't changed much in a > *long* time, not that this means it isn't broken, just that it might > also be worth looking at other odd memory bugs to see if there is > chance they are wandering around and stomping on memory ... Not sure if it's the root cause or not, but I am looking at this reference drop in cipso_v4_doi_remove: https://elixir.bootlin.com/linux/v5.12-rc1/source/net/ipv4/cipso_ipv4.c#L522 The thing is that it does not remove from the list if reference is not 0, right? So what if I send 1000 of netlink remove messages? Will it drain refcount to 0? I did not read all involved code, but the typical pattern is to drop refcount and always remove from the list. Then the last use will delete the object. Does it make any sense?
[PATCH v2 00/12] pinctrl: add BCM63XX pincontrol support
First of all, I've based this on the patches sent by Jonas Gorski back in 2016: https://www.spinics.net/lists/linux-gpio/msg15983.html http://patchwork.ozlabs.org/project/linux-gpio/patch/1471604025-21575-2-git-send-email-jonas.gor...@gmail.com/ I've tried to address all coments from Linus Walleij, but I know that this may still need some other modifications This patchset adds appropriate binding documentation and drivers for pin controller cores found in the BCM63XX MIPS SoCs currently supported. While the GPIO part is always the same, the pinmux part varies quite a lot between different SoCs. Sometimes they have defined groups which can be muxed into different functions, sometimes each function has a different group. Sometimes you can mux individual pins. Often it is a combination of single pins and groups. Some core versions require the GPIO direction to be set according to the function, most do not. Sometimes the mux register(s) contain bits for unrelated other functions. v2: introduce changes suggested by Linus Walleij and remove interrupts - In order to use GPIO_REGMAP, the need to get gpio_chip from gpio_regmap and use it for pinctrl_add_gpio_range() and gpio_chip.direction_input() and gpio_chip.direction_output(). Álvaro Fernández Rojas (12): Documentation: add BCM6328 pincontroller binding documentation pinctrl: add a pincontrol driver for BCM6328 Documentation: add BCM6358 pincontroller binding documentation pinctrl: add a pincontrol driver for BCM6358 Documentation: add BCM6362 pincontroller binding documentation pinctrl: add a pincontrol driver for BCM6362 Documentation: add BCM6368 pincontroller binding documentation pinctrl: add a pincontrol driver for BCM6368 Documentation: add BCM63268 pincontroller binding documentation pinctrl: add a pincontrol driver for BCM63268 Documentation: add BCM6318 pincontroller binding documentation pinctrl: add a pincontrol driver for BCM6318 .../pinctrl/brcm,bcm6318-pinctrl.yaml | 161 .../pinctrl/brcm,bcm63268-pinctrl.yaml| 182 + .../pinctrl/brcm,bcm6328-pinctrl.yaml | 145 .../pinctrl/brcm,bcm6358-pinctrl.yaml | 111 +++ .../pinctrl/brcm,bcm6362-pinctrl.yaml | 224 ++ .../pinctrl/brcm,bcm6368-pinctrl.yaml | 235 ++ drivers/pinctrl/bcm/Kconfig | 68 ++ drivers/pinctrl/bcm/Makefile | 6 + drivers/pinctrl/bcm/pinctrl-bcm6318.c | 574 ++ drivers/pinctrl/bcm/pinctrl-bcm63268.c| 726 ++ drivers/pinctrl/bcm/pinctrl-bcm6328.c | 481 drivers/pinctrl/bcm/pinctrl-bcm6358.c | 429 +++ drivers/pinctrl/bcm/pinctrl-bcm6362.c | 699 + drivers/pinctrl/bcm/pinctrl-bcm6368.c | 587 ++ 14 files changed, 4628 insertions(+) create mode 100644 Documentation/devicetree/bindings/pinctrl/brcm,bcm6318-pinctrl.yaml create mode 100644 Documentation/devicetree/bindings/pinctrl/brcm,bcm63268-pinctrl.yaml create mode 100644 Documentation/devicetree/bindings/pinctrl/brcm,bcm6328-pinctrl.yaml create mode 100644 Documentation/devicetree/bindings/pinctrl/brcm,bcm6358-pinctrl.yaml create mode 100644 Documentation/devicetree/bindings/pinctrl/brcm,bcm6362-pinctrl.yaml create mode 100644 Documentation/devicetree/bindings/pinctrl/brcm,bcm6368-pinctrl.yaml create mode 100644 drivers/pinctrl/bcm/pinctrl-bcm6318.c create mode 100644 drivers/pinctrl/bcm/pinctrl-bcm63268.c create mode 100644 drivers/pinctrl/bcm/pinctrl-bcm6328.c create mode 100644 drivers/pinctrl/bcm/pinctrl-bcm6358.c create mode 100644 drivers/pinctrl/bcm/pinctrl-bcm6362.c create mode 100644 drivers/pinctrl/bcm/pinctrl-bcm6368.c -- 2.20.1
[PATCH v2 02/12] pinctrl: add a pincontrol driver for BCM6328
Add a pincontrol driver for BCM6328. BCM628 supports muxing 32 pins as GPIOs, as LEDs for the integrated LED controller, or various other functions. Its pincontrol mux registers also control other aspects, like switching the second USB port between host and device mode. Signed-off-by: Álvaro Fernández Rojas Signed-off-by: Jonas Gorski --- v2: switch to GPIO_REGMAP drivers/pinctrl/bcm/Kconfig | 13 + drivers/pinctrl/bcm/Makefile | 1 + drivers/pinctrl/bcm/pinctrl-bcm6328.c | 481 ++ 3 files changed, 495 insertions(+) create mode 100644 drivers/pinctrl/bcm/pinctrl-bcm6328.c diff --git a/drivers/pinctrl/bcm/Kconfig b/drivers/pinctrl/bcm/Kconfig index 0ed14de0134c..76728f097c25 100644 --- a/drivers/pinctrl/bcm/Kconfig +++ b/drivers/pinctrl/bcm/Kconfig @@ -29,6 +29,19 @@ config PINCTRL_BCM2835 help Say Y here to enable the Broadcom BCM2835 GPIO driver. +config PINCTRL_BCM6328 + bool "Broadcom BCM6328 GPIO driver" + depends on OF_GPIO && (BMIPS_GENERIC || COMPILE_TEST) + select GPIO_REGMAP + select GPIOLIB_IRQCHIP + select IRQ_DOMAIN_HIERARCHY + select PINMUX + select PINCONF + select GENERIC_PINCONF + default BMIPS_GENERIC + help + Say Y here to enable the Broadcom BCM6328 GPIO driver. + config PINCTRL_IPROC_GPIO bool "Broadcom iProc GPIO (with PINCONF) driver" depends on OF_GPIO && (ARCH_BCM_IPROC || COMPILE_TEST) diff --git a/drivers/pinctrl/bcm/Makefile b/drivers/pinctrl/bcm/Makefile index 79d5e49fdd9a..7e7c6e25b26d 100644 --- a/drivers/pinctrl/bcm/Makefile +++ b/drivers/pinctrl/bcm/Makefile @@ -3,6 +3,7 @@ obj-$(CONFIG_PINCTRL_BCM281XX) += pinctrl-bcm281xx.o obj-$(CONFIG_PINCTRL_BCM2835) += pinctrl-bcm2835.o +obj-$(CONFIG_PINCTRL_BCM6328) += pinctrl-bcm6328.o obj-$(CONFIG_PINCTRL_IPROC_GPIO) += pinctrl-iproc-gpio.o obj-$(CONFIG_PINCTRL_CYGNUS_MUX) += pinctrl-cygnus-mux.o obj-$(CONFIG_PINCTRL_NS) += pinctrl-ns.o diff --git a/drivers/pinctrl/bcm/pinctrl-bcm6328.c b/drivers/pinctrl/bcm/pinctrl-bcm6328.c new file mode 100644 index ..f2b1a14e7903 --- /dev/null +++ b/drivers/pinctrl/bcm/pinctrl-bcm6328.c @@ -0,0 +1,481 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Driver for BCM6328 GPIO unit (pinctrl + GPIO) + * + * Copyright (C) 2021 Álvaro Fernández Rojas + * Copyright (C) 2016 Jonas Gorski + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "../core.h" +#include "../pinctrl-utils.h" + +#define MODULE_NAME"bcm6328-pinctrl" +#define BCM6328_BANK_GPIOS 32 +#define BCM6328_NUM_GPIOS 32 + +#define BCM6328_DIROUT_REG 0x04 +#define BCM6328_DATA_REG 0x0c +#define BCM6328_MODE_REG 0x18 +#define BCM6328_MUX_HI_REG 0x1c +#define BCM6328_MUX_LO_REG 0x20 +#define BCM6328_MUX_OTHER_REG 0x24 + +struct bcm6328_pingroup { + const char *name; + const unsigned * const pins; + const unsigned num_pins; +}; + +struct bcm6328_function { + const char *name; + const char * const *groups; + const unsigned num_groups; + + unsigned mode_val:1; + unsigned mux_val:2; +}; + +struct bcm6328_pinctrl { + struct device *dev; + struct regmap *regs; + + struct pinctrl_dev *pctl_dev; + struct pinctrl_desc pctl_desc; + struct pinctrl_gpio_range gpio_range; +}; + +static const struct pinctrl_pin_desc bcm6328_pins[] = { + PINCTRL_PIN(0, "gpio0"), + PINCTRL_PIN(1, "gpio1"), + PINCTRL_PIN(2, "gpio2"), + PINCTRL_PIN(3, "gpio3"), + PINCTRL_PIN(4, "gpio4"), + PINCTRL_PIN(5, "gpio5"), + PINCTRL_PIN(6, "gpio6"), + PINCTRL_PIN(7, "gpio7"), + PINCTRL_PIN(8, "gpio8"), + PINCTRL_PIN(9, "gpio9"), + PINCTRL_PIN(10, "gpio10"), + PINCTRL_PIN(11, "gpio11"), + PINCTRL_PIN(12, "gpio12"), + PINCTRL_PIN(13, "gpio13"), + PINCTRL_PIN(14, "gpio14"), + PINCTRL_PIN(15, "gpio15"), + PINCTRL_PIN(16, "gpio16"), + PINCTRL_PIN(17, "gpio17"), + PINCTRL_PIN(18, "gpio18"), + PINCTRL_PIN(19, "gpio19"), + PINCTRL_PIN(20, "gpio20"), + PINCTRL_PIN(21, "gpio21"), + PINCTRL_PIN(22, "gpio22"), + PINCTRL_PIN(23, "gpio23"), + PINCTRL_PIN(24, "gpio24"), + PINCTRL_PIN(25, "gpio25"), + PINCTRL_PIN(26, "gpio26"), + PINCTRL_PIN(27, "gpio27"), + PINCTRL_PIN(28, "gpio28"), + PINCTRL_PIN(29, "gpio29"), + PINCTRL_PIN(30, "gpio30"), + PINCTRL_PIN(31, "gpio31"), + + /* +* No idea where they really are; so let's put them according +* to their mux offsets. +*/ + PINCTRL_PIN(36, "hsspi_cs1"), + PINCTRL_PIN(38, "usb_p2"), +}; + +static unsigned gpio0_pins[] = { 0 }; +static unsigned gpio1_pins[] = { 1 }; +static unsigned
[PATCH v2 01/12] Documentation: add BCM6328 pincontroller binding documentation
Add binding documentation for the pincontrol core found in BCM6328 SoCs. Signed-off-by: Álvaro Fernández Rojas Signed-off-by: Jonas Gorski --- v2: remove interrupts .../pinctrl/brcm,bcm6328-pinctrl.yaml | 145 ++ 1 file changed, 145 insertions(+) create mode 100644 Documentation/devicetree/bindings/pinctrl/brcm,bcm6328-pinctrl.yaml diff --git a/Documentation/devicetree/bindings/pinctrl/brcm,bcm6328-pinctrl.yaml b/Documentation/devicetree/bindings/pinctrl/brcm,bcm6328-pinctrl.yaml new file mode 100644 index ..8b1201a763e9 --- /dev/null +++ b/Documentation/devicetree/bindings/pinctrl/brcm,bcm6328-pinctrl.yaml @@ -0,0 +1,145 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/pinctrl/brcm,bcm6328-pinctrl.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Broadcom BCM6328 pin controller + +maintainers: + - Álvaro Fernández Rojas + - Jonas Gorski + +description: |+ + The pin controller node should be the child of a syscon node. + + Refer to the the bindings described in + Documentation/devicetree/bindings/mfd/syscon.yaml + +properties: + compatible: +const: brcm,bcm6328-pinctrl + + gpio-controller: true + + '#gpio-cells': +description: + Specifies the pin number and flags, as defined in + include/dt-bindings/gpio/gpio.h +const: 2 + +patternProperties: + '^.*$': +if: + type: object +then: + properties: +function: + $ref: "/schemas/types.yaml#/definitions/string" + enum: [ serial_led_data, serial_led_clk, inet_act_led, pcie_clkreq, + led, ephy0_act_led, ephy1_act_led, ephy2_act_led, + ephy3_act_led, hsspi_cs1, usb_device_port, usb_host_port ] + +pins: + $ref: "/schemas/types.yaml#/definitions/string" + enum: [ gpio6, gpio7, gpio11, gpio16, gpio17, gpio18, gpio19, + gpio20, gpio25, gpio26, gpio27, gpio28, hsspi_cs1, + usb_port1 ] + +required: + - compatible + - gpio-controller + - '#gpio-cells' + +additionalProperties: false + +examples: + - | +gpio@1080 { + compatible = "syscon", "simple-mfd"; + reg = <0x1080 0x80>; + + pinctrl: pinctrl { +compatible = "brcm,bcm6328-pinctrl"; + +gpio-controller; +#gpio-cells = <2>; + +pinctrl_serial_led: serial_led { + pinctrl_serial_led_data: serial_led_data { +function = "serial_led_data"; +pins = "gpio6"; + }; + + pinctrl_serial_led_clk: serial_led_clk { +function = "serial_led_clk"; +pins = "gpio7"; + }; +}; + +pinctrl_inet_act_led: inet_act_led { + function = "inet_act_led"; + pins = "gpio11"; +}; + +pinctrl_pcie_clkreq: pcie_clkreq { + function = "pcie_clkreq"; + pins = "gpio16"; +}; + +pinctrl_ephy0_spd_led: ephy0_spd_led { + function = "led"; + pins = "gpio17"; +}; + +pinctrl_ephy1_spd_led: ephy1_spd_led { + function = "led"; + pins = "gpio18"; +}; + +pinctrl_ephy2_spd_led: ephy2_spd_led { + function = "led"; + pins = "gpio19"; +}; + +pinctrl_ephy3_spd_led: ephy3_spd_led { + function = "led"; + pins = "gpio20"; +}; + +pinctrl_ephy0_act_led: ephy0_act_led { + function = "ephy0_act_led"; + pins = "gpio25"; +}; + +pinctrl_ephy1_act_led: ephy1_act_led { + function = "ephy1_act_led"; + pins = "gpio26"; +}; + +pinctrl_ephy2_act_led: ephy2_act_led { + function = "ephy2_act_led"; + pins = "gpio27"; +}; + +pinctrl_ephy3_act_led: ephy3_act_led { + function = "ephy3_act_led"; + pins = "gpio28"; +}; + +pinctrl_hsspi_cs1: hsspi_cs1 { + function = "hsspi_cs1"; + pins = "hsspi_cs1"; +}; + +pinctrl_usb_port1_device: usb_port1_device { + function = "usb_device_port"; + pins = "usb_port1"; +}; + +pinctrl_usb_port1_host: usb_port1_host { + function = "usb_host_port"; + pins = "usb_port1"; +}; + }; +}; -- 2.20.1
[PATCH v2 06/12] pinctrl: add a pincontrol driver for BCM6362
Add a pincotrol driver for BCM6362. BCM6362 allows muxing individual GPIO pins to the LED controller, to be available by the integrated wifi, or other functions. It also supports overlay groups, of which only NAND is documented. Signed-off-by: Álvaro Fernández Rojas Signed-off-by: Jonas Gorski --- v2: switch to GPIO_REGMAP drivers/pinctrl/bcm/Kconfig | 11 + drivers/pinctrl/bcm/Makefile | 1 + drivers/pinctrl/bcm/pinctrl-bcm6362.c | 699 ++ 3 files changed, 711 insertions(+) create mode 100644 drivers/pinctrl/bcm/pinctrl-bcm6362.c diff --git a/drivers/pinctrl/bcm/Kconfig b/drivers/pinctrl/bcm/Kconfig index 998331219c57..3dcceba17cd1 100644 --- a/drivers/pinctrl/bcm/Kconfig +++ b/drivers/pinctrl/bcm/Kconfig @@ -53,6 +53,17 @@ config PINCTRL_BCM6358 help Say Y here to enable the Broadcom BCM6358 GPIO driver. +config PINCTRL_BCM6362 + bool "Broadcom BCM6362 GPIO driver" + depends on OF_GPIO && (BMIPS_GENERIC || COMPILE_TEST) + select PINMUX + select PINCONF + select GENERIC_PINCONF + select MFD_SYSCON + default BMIPS_GENERIC + help + Say Y here to enable the Broadcom BCM6362 GPIO driver. + config PINCTRL_IPROC_GPIO bool "Broadcom iProc GPIO (with PINCONF) driver" depends on OF_GPIO && (ARCH_BCM_IPROC || COMPILE_TEST) diff --git a/drivers/pinctrl/bcm/Makefile b/drivers/pinctrl/bcm/Makefile index 794d07d97754..0ade52a390cb 100644 --- a/drivers/pinctrl/bcm/Makefile +++ b/drivers/pinctrl/bcm/Makefile @@ -5,6 +5,7 @@ obj-$(CONFIG_PINCTRL_BCM281XX) += pinctrl-bcm281xx.o obj-$(CONFIG_PINCTRL_BCM2835) += pinctrl-bcm2835.o obj-$(CONFIG_PINCTRL_BCM6328) += pinctrl-bcm6328.o obj-$(CONFIG_PINCTRL_BCM6358) += pinctrl-bcm6358.o +obj-$(CONFIG_PINCTRL_BCM6362) += pinctrl-bcm6362.o obj-$(CONFIG_PINCTRL_IPROC_GPIO) += pinctrl-iproc-gpio.o obj-$(CONFIG_PINCTRL_CYGNUS_MUX) += pinctrl-cygnus-mux.o obj-$(CONFIG_PINCTRL_NS) += pinctrl-ns.o diff --git a/drivers/pinctrl/bcm/pinctrl-bcm6362.c b/drivers/pinctrl/bcm/pinctrl-bcm6362.c new file mode 100644 index ..1ef83161f836 --- /dev/null +++ b/drivers/pinctrl/bcm/pinctrl-bcm6362.c @@ -0,0 +1,699 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Driver for BCM6362 GPIO unit (pinctrl + GPIO) + * + * Copyright (C) 2021 Álvaro Fernández Rojas + * Copyright (C) 2016 Jonas Gorski + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "../core.h" +#include "../pinctrl-utils.h" + +#define MODULE_NAME"bcm6362-pinctrl" +#define BCM6362_BANK_GPIOS 32 +#define BCM6362_NUM_GPIOS 48 +#define BCM6362_NUM_LEDS 24 + +#define BCM6362_DIROUT_REG 0x04 +#define BCM6362_DATA_REG 0x0c +#define BCM6362_LED_REG0x10 +#define BCM6362_MODE_REG 0x18 +#define BCM6362_CTRL_REG 0x1c +#define BCM6362_BASEMODE_REG 0x38 +#define BASEMODE_NAND BIT(2) + +enum bcm6362_pinctrl_reg { + BCM6362_LEDCTRL, + BCM6362_MODE, + BCM6362_CTRL, + BCM6362_BASEMODE, +}; + +struct bcm6362_pingroup { + const char *name; + const unsigned * const pins; + const unsigned num_pins; +}; + +struct bcm6362_function { + const char *name; + const char * const *groups; + const unsigned num_groups; + + enum bcm6362_pinctrl_reg reg; + uint32_t basemode_mask; +}; + +struct bcm6362_pinctrl { + struct device *dev; + struct regmap *regs; + + struct pinctrl_dev *pctl_dev; + struct pinctrl_desc pctl_desc; + struct pinctrl_gpio_range gpio_range; +}; + +#define BCM6362_PIN(a, b, mask)\ + { \ + .number = a,\ + .name = b, \ + .drv_data = (void *)(mask), \ + } + +static const struct pinctrl_pin_desc bcm6362_pins[] = { + PINCTRL_PIN(0, "gpio0"), + PINCTRL_PIN(1, "gpio1"), + PINCTRL_PIN(2, "gpio2"), + PINCTRL_PIN(3, "gpio3"), + PINCTRL_PIN(4, "gpio4"), + PINCTRL_PIN(5, "gpio5"), + PINCTRL_PIN(6, "gpio6"), + PINCTRL_PIN(7, "gpio7"), + BCM6362_PIN(8, "gpio8", BASEMODE_NAND), + PINCTRL_PIN(9, "gpio9"), + PINCTRL_PIN(10, "gpio10"), + PINCTRL_PIN(11, "gpio11"), + BCM6362_PIN(12, "gpio12", BASEMODE_NAND), + BCM6362_PIN(13, "gpio13", BASEMODE_NAND), + BCM6362_PIN(14, "gpio14", BASEMODE_NAND), + BCM6362_PIN(15, "gpio15", BASEMODE_NAND), + BCM6362_PIN(16, "gpio16", BASEMODE_NAND), + BCM6362_PIN(17, "gpio17", BASEMODE_NAND), + BCM6362_PIN(18, "gpio18", BASEMODE_NAND), + BCM6362_PIN(19, "gpio19", BASEMODE_NAND), + BCM6362_PIN(20, "gpio20", BASEMODE_NAND), + BCM6362_PIN(21, "gpio21",
[PATCH v2 03/12] Documentation: add BCM6358 pincontroller binding documentation
Add binding documentation for the pincontrol core found in BCM6358 SoCs. Signed-off-by: Álvaro Fernández Rojas Signed-off-by: Jonas Gorski --- v2: remove interrupts .../pinctrl/brcm,bcm6358-pinctrl.yaml | 111 ++ 1 file changed, 111 insertions(+) create mode 100644 Documentation/devicetree/bindings/pinctrl/brcm,bcm6358-pinctrl.yaml diff --git a/Documentation/devicetree/bindings/pinctrl/brcm,bcm6358-pinctrl.yaml b/Documentation/devicetree/bindings/pinctrl/brcm,bcm6358-pinctrl.yaml new file mode 100644 index ..822d1ca8789c --- /dev/null +++ b/Documentation/devicetree/bindings/pinctrl/brcm,bcm6358-pinctrl.yaml @@ -0,0 +1,111 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/pinctrl/brcm,bcm6358-pinctrl.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Broadcom BCM6358 pin controller + +maintainers: + - Álvaro Fernández Rojas + - Jonas Gorski + +description: |+ + The pin controller node should be the child of a syscon node. + + Refer to the the bindings described in + Documentation/devicetree/bindings/mfd/syscon.yaml + +properties: + compatible: +const: brcm,bcm6358-pinctrl + + gpio-controller: true + + '#gpio-cells': +description: + Specifies the pin number and flags, as defined in + include/dt-bindings/gpio/gpio.h +const: 2 + +patternProperties: + '^.*$': +if: + type: object +then: + properties: +function: + $ref: "/schemas/types.yaml#/definitions/string" + enum: [ ebi_cs, uart1, serial_led, legacy_led, led, spi_cs, utopia, + pwm_syn_clk, sys_irq ] + +pins: + $ref: "/schemas/types.yaml#/definitions/string" + enum: [ ebi_cs_grp, uart1_grp, serial_led_grp, legacy_led_grp, + led_grp, spi_cs_grp, utopia_grp, pwm_syn_clk, sys_irq_grp ] + +required: + - compatible + - gpio-controller + - '#gpio-cells' + +additionalProperties: false + +examples: + - | +gpio@fffe0080 { + compatible = "syscon", "simple-mfd"; + reg = <0xfffe0080 0x80>; + + pinctrl: pinctrl { +compatible = "brcm,bcm6358-pinctrl"; + +gpio-controller; +#gpio-cells = <2>; + +pinctrl_ebi_cs: ebi_cs { + function = "ebi_cs"; + groups = "ebi_cs_grp"; +}; + +pinctrl_uart1: uart1 { + function = "uart1"; + groups = "uart1_grp"; +}; + +pinctrl_serial_led: serial_led { + function = "serial_led"; + groups = "serial_led_grp"; +}; + +pinctrl_legacy_led: legacy_led { + function = "legacy_led"; + groups = "legacy_led_grp"; +}; + +pinctrl_led: led { + function = "led"; + groups = "led_grp"; +}; + +pinctrl_spi_cs_23: spi_cs { + function = "spi_cs"; + groups = "spi_cs_grp"; +}; + +pinctrl_utopia: utopia { + function = "utopia"; + groups = "utopia_grp"; +}; + +pinctrl_pwm_syn_clk: pwm_syn_clk { + function = "pwm_syn_clk"; + groups = "pwm_syn_clk_grp"; +}; + +pinctrl_sys_irq: sys_irq { + function = "sys_irq"; + groups = "sys_irq_grp"; +}; + }; +}; -- 2.20.1
[PATCH v2 07/12] Documentation: add BCM6368 pincontroller binding documentation
Add binding documentation for the pincontrol core found in BCM6368 SoCs. Signed-off-by: Álvaro Fernández Rojas Signed-off-by: Jonas Gorski --- v2: remove interrupts .../pinctrl/brcm,bcm6368-pinctrl.yaml | 235 ++ 1 file changed, 235 insertions(+) create mode 100644 Documentation/devicetree/bindings/pinctrl/brcm,bcm6368-pinctrl.yaml diff --git a/Documentation/devicetree/bindings/pinctrl/brcm,bcm6368-pinctrl.yaml b/Documentation/devicetree/bindings/pinctrl/brcm,bcm6368-pinctrl.yaml new file mode 100644 index ..226f202bb8d6 --- /dev/null +++ b/Documentation/devicetree/bindings/pinctrl/brcm,bcm6368-pinctrl.yaml @@ -0,0 +1,235 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/pinctrl/brcm,bcm6368-pinctrl.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Broadcom BCM6368 pin controller + +maintainers: + - Álvaro Fernández Rojas + - Jonas Gorski + +description: |+ + The pin controller node should be the child of a syscon node. + + Refer to the the bindings described in + Documentation/devicetree/bindings/mfd/syscon.yaml + +properties: + compatible: +const: brcm,bcm6368-pinctrl + + gpio-controller: true + + '#gpio-cells': +description: + Specifies the pin number and flags, as defined in + include/dt-bindings/gpio/gpio.h +const: 2 + +patternProperties: + '^.*$': +if: + type: object +then: + properties: +function: + $ref: "/schemas/types.yaml#/definitions/string" + enum: [ analog_afe_0, analog_afe_1, sys_irq, serial_led_data, + serial_led_clk, inet_led, ephy0_led, ephy1_led, ephy2_led, + ephy3_led, robosw_led_data, robosw_led_clk, robosw_led0, + robosw_led1, usb_device_led, pci_req1, pci_gnt1, pci_intb, + pci_req0, pci_gnt0, pcmcia_cd1, pcmcia_cd2, pcmcia_vs1, + pcmcia_vs2, ebi_cs2, ebi_cs3, spi_cs2, spi_cs3, spi_cs4, + spi_cs5, uart1 ] + +pins: + $ref: "/schemas/types.yaml#/definitions/string" + enum: [ gpio0, gpio1, gpio2, gpio3, gpio4, gpio5, gpio6, gpio7, + gpio8, gpio9, gpio10, gpio11, gpio12, gpio13, gpio14, + gpio16, gpio17, gpio18, gpio19, gpio20, gpio22, gpio23, + gpio24, gpio25, gpio26, gpio27, gpio28, gpio29, gpio30, + gpio31, uart1_grp ] + +required: + - compatible + - gpio-controller + - '#gpio-cells' + +additionalProperties: false + +examples: + - | +gpio@1080 { + compatible = "syscon", "simple-mfd"; + reg = <0x1080 0x80>; + + pinctrl: pinctrl { +compatible = "brcm,bcm6368-pinctrl"; + +gpio-controller; +#gpio-cells = <2>; + +pinctrl_analog_afe_0: analog_afe_0 { + function = "analog_afe_0"; + pins = "gpio0"; +}; + +pinctrl_analog_afe_1: analog_afe_1 { + function = "analog_afe_1"; + pins = "gpio1"; +}; + +pinctrl_sys_irq: sys_irq { + function = "sys_irq"; + pins = "gpio2"; +}; + +pinctrl_serial_led: serial_led { + pinctrl_serial_led_data: serial_led_data { +function = "serial_led_data"; +pins = "gpio3"; + }; + + pinctrl_serial_led_clk: serial_led_clk { +function = "serial_led_clk"; +pins = "gpio4"; + }; +}; + +pinctrl_inet_led: inet_led { + function = "inet_led"; + pins = "gpio5"; +}; + +pinctrl_ephy0_led: ephy0_led { + function = "ephy0_led"; + pins = "gpio6"; +}; + +pinctrl_ephy1_led: ephy1_led { + function = "ephy1_led"; + pins = "gpio7"; +}; + +pinctrl_ephy2_led: ephy2_led { + function = "ephy2_led"; + pins = "gpio8"; +}; + +pinctrl_ephy3_led: ephy3_led { + function = "ephy3_led"; + pins = "gpio9"; +}; + +pinctrl_robosw_led_data: robosw_led_data { + function = "robosw_led_data"; + pins = "gpio10"; +}; + +pinctrl_robosw_led_clk: robosw_led_clk { + function = "robosw_led_clk"; + pins = "gpio11"; +}; + +pinctrl_robosw_led0: robosw_led0 { + function = "robosw_led0"; + pins = "gpio12"; +}; + +pinctrl_robosw_led1: robosw_led1 { + function = "robosw_led1"; + pins = "gpio13"; +}; + +pinctrl_usb_device_led: usb_device_led { + function = "usb_device_led"; + pins = "gpio14"; +}; + +pinctrl_pci: pci { + pinctrl_pci_req1: pci_req1 { +function = "pci_req1"; +pins = "gpio16"; + }; + + pinctrl_pci_gnt1: pci_gnt1 { +function = "pci_gnt1"; +pins = "gpio17
[PATCH v2 04/12] pinctrl: add a pincontrol driver for BCM6358
Add a pincotrol driver for BCM6358. BCM6358 allow overlaying different functions onto the GPIO pins. It does not support configuring individual pins but only whole groups. These groups may overlap, and still require the directions to be set correctly in the GPIO register. In addition the functions register controls other, not directly mux related functions. Signed-off-by: Álvaro Fernández Rojas Signed-off-by: Jonas Gorski --- v2: switch to GPIO_REGMAP drivers/pinctrl/bcm/Kconfig | 11 + drivers/pinctrl/bcm/Makefile | 1 + drivers/pinctrl/bcm/pinctrl-bcm6358.c | 429 ++ 3 files changed, 441 insertions(+) create mode 100644 drivers/pinctrl/bcm/pinctrl-bcm6358.c diff --git a/drivers/pinctrl/bcm/Kconfig b/drivers/pinctrl/bcm/Kconfig index 76728f097c25..998331219c57 100644 --- a/drivers/pinctrl/bcm/Kconfig +++ b/drivers/pinctrl/bcm/Kconfig @@ -42,6 +42,17 @@ config PINCTRL_BCM6328 help Say Y here to enable the Broadcom BCM6328 GPIO driver. +config PINCTRL_BCM6358 + bool "Broadcom BCM6358 GPIO driver" + depends on OF_GPIO && (BMIPS_GENERIC || COMPILE_TEST) + select PINMUX + select PINCONF + select GENERIC_PINCONF + select MFD_SYSCON + default BMIPS_GENERIC + help + Say Y here to enable the Broadcom BCM6358 GPIO driver. + config PINCTRL_IPROC_GPIO bool "Broadcom iProc GPIO (with PINCONF) driver" depends on OF_GPIO && (ARCH_BCM_IPROC || COMPILE_TEST) diff --git a/drivers/pinctrl/bcm/Makefile b/drivers/pinctrl/bcm/Makefile index 7e7c6e25b26d..794d07d97754 100644 --- a/drivers/pinctrl/bcm/Makefile +++ b/drivers/pinctrl/bcm/Makefile @@ -4,6 +4,7 @@ obj-$(CONFIG_PINCTRL_BCM281XX) += pinctrl-bcm281xx.o obj-$(CONFIG_PINCTRL_BCM2835) += pinctrl-bcm2835.o obj-$(CONFIG_PINCTRL_BCM6328) += pinctrl-bcm6328.o +obj-$(CONFIG_PINCTRL_BCM6358) += pinctrl-bcm6358.o obj-$(CONFIG_PINCTRL_IPROC_GPIO) += pinctrl-iproc-gpio.o obj-$(CONFIG_PINCTRL_CYGNUS_MUX) += pinctrl-cygnus-mux.o obj-$(CONFIG_PINCTRL_NS) += pinctrl-ns.o diff --git a/drivers/pinctrl/bcm/pinctrl-bcm6358.c b/drivers/pinctrl/bcm/pinctrl-bcm6358.c new file mode 100644 index ..5dd0c66d9ed7 --- /dev/null +++ b/drivers/pinctrl/bcm/pinctrl-bcm6358.c @@ -0,0 +1,429 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Driver for BCM6358 GPIO unit (pinctrl + GPIO) + * + * Copyright (C) 2021 Álvaro Fernández Rojas + * Copyright (C) 2016 Jonas Gorski + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "../core.h" +#include "../pinctrl-utils.h" + +#define MODULE_NAME"bcm6358-pinctrl" +#define BCM6358_BANK_GPIOS 32 +#define BCM6358_NUM_GPIOS 40 + +#define BCM6358_DIROUT_REG 0x04 +#define BCM6358_DATA_REG 0x0c +#define BCM6358_MODE_REG 0x18 + +#define BCM6358_MODE_MUX_NONE 0 +#define BCM6358_MODE_MUX_EBI_CSBIT(5) +#define BCM6358_MODE_MUX_UART1 BIT(6) +#define BCM6358_MODE_MUX_SPI_CSBIT(7) +#define BCM6358_MODE_MUX_ASYNC_MODEM BIT(8) +#define BCM6358_MODE_MUX_LEGACY_LEDBIT(9) +#define BCM6358_MODE_MUX_SERIAL_LEDBIT(10) +#define BCM6358_MODE_MUX_LED BIT(11) +#define BCM6358_MODE_MUX_UTOPIABIT(12) +#define BCM6358_MODE_MUX_CLKRSTBIT(13) +#define BCM6358_MODE_MUX_PWM_SYN_CLK BIT(14) +#define BCM6358_MODE_MUX_SYS_IRQ BIT(15) + +struct bcm6358_pingroup { + const char *name; + const unsigned * const pins; + const unsigned num_pins; + + const uint16_t mode_val; + + /* non-GPIO function muxes require the gpio direction to be set */ + const uint16_t direction; +}; + +struct bcm6358_function { + const char *name; + const char * const *groups; + const unsigned num_groups; +}; + +struct bcm6358_pinctrl { + struct device *dev; + struct regmap *regs; + struct regmap_field *overlays; + + struct pinctrl_dev *pctl_dev; + struct gpio_chip *gpio_chip; + struct pinctrl_desc pctl_desc; + struct pinctrl_gpio_range gpio_range; +}; + +#define BCM6358_GPIO_PIN(a, b, bit1, bit2, bit3) \ + { \ + .number = a,\ + .name = b, \ + .drv_data = (void *)(BCM6358_MODE_MUX_##bit1 | \ +BCM6358_MODE_MUX_##bit2 | \ +BCM6358_MODE_MUX_##bit3), \ + } + +static const struct pinctrl_pin_desc bcm6358_pins[] = { + BCM6358_GPIO_PIN(0, "gpio0", LED, NONE, NONE), + BCM6358_GPIO_PIN(1, "gpio1", LED, NONE, NONE), + BCM6358_GPIO_PIN(2, "gpio2", LED, NONE, NONE), + BCM6358_GPIO_PIN(3, "gpi
[PATCH v2 05/12] Documentation: add BCM6362 pincontroller binding documentation
Add binding documentation for the pincontrol core found in BCM6362 SoCs. Signed-off-by: Álvaro Fernández Rojas Signed-off-by: Jonas Gorski --- v2: remove interrupts .../pinctrl/brcm,bcm6362-pinctrl.yaml | 224 ++ 1 file changed, 224 insertions(+) create mode 100644 Documentation/devicetree/bindings/pinctrl/brcm,bcm6362-pinctrl.yaml diff --git a/Documentation/devicetree/bindings/pinctrl/brcm,bcm6362-pinctrl.yaml b/Documentation/devicetree/bindings/pinctrl/brcm,bcm6362-pinctrl.yaml new file mode 100644 index ..82e72778eb66 --- /dev/null +++ b/Documentation/devicetree/bindings/pinctrl/brcm,bcm6362-pinctrl.yaml @@ -0,0 +1,224 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/pinctrl/brcm,bcm6362-pinctrl.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Broadcom BCM6362 pin controller + +maintainers: + - Álvaro Fernández Rojas + - Jonas Gorski + +description: |+ + The pin controller node should be the child of a syscon node. + + Refer to the the bindings described in + Documentation/devicetree/bindings/mfd/syscon.yaml + +properties: + compatible: +const: brcm,bcm6362-pinctrl + + gpio-controller: true + + '#gpio-cells': +description: + Specifies the pin number and flags, as defined in + include/dt-bindings/gpio/gpio.h +const: 2 + +patternProperties: + '^.*$': +if: + type: object +then: + properties: +function: + $ref: "/schemas/types.yaml#/definitions/string" + enum: [ usb_device_led, sys_irq, serial_led_clk, serial_led_data, + robosw_led_data, robosw_led_clk, robosw_led0, robosw_led1, + inet_led, spi_cs2, spi_cs3, ntr_pulse, uart1_scts, + uart1_srts, uart1_sdin, uart1_sdout, adsl_spi_miso, + adsl_spi_mosi, adsl_spi_clk, adsl_spi_cs, ephy0_led, + ephy1_led, ephy2_led, ephy3_led, ext_irq0, ext_irq1, + ext_irq2, ext_irq3, nand ] + +pins: + $ref: "/schemas/types.yaml#/definitions/string" + enum: [ gpio0, gpio1, gpio2, gpio3, gpio4, gpio5, gpio6, gpio7, + gpio8, gpio9, gpio10, gpio11, gpio12, gpio13, gpio14, + gpio15, gpio16, gpio17, gpio18, gpio19, gpio20, gpio21, + gpio22, gpio23, gpio24, gpio25, gpio26, gpio27, nand_grp ] + +required: + - compatible + - gpio-controller + - '#gpio-cells' + +additionalProperties: false + +examples: + - | +gpio@1080 { + compatible = "syscon", "simple-mfd"; + reg = <0x1080 0x80>; + + pinctrl: pinctrl { +compatible = "brcm,bcm6362-pinctrl"; + +gpio-controller; +#gpio-cells = <2>; + +pinctrl_usb_device_led: usb_device_led { + function = "usb_device_led"; + pins = "gpio0"; +}; + +pinctrl_sys_irq: sys_irq { + function = "sys_irq"; + pins = "gpio1"; +}; + +pinctrl_serial_led: serial_led { + pinctrl_serial_led_clk: serial_led_clk { +function = "serial_led_clk"; +pins = "gpio2"; + }; + + pinctrl_serial_led_data: serial_led_data { +function = "serial_led_data"; +pins = "gpio3"; + }; +}; + +pinctrl_robosw_led_data: robosw_led_data { + function = "robosw_led_data"; + pins = "gpio4"; +}; + +pinctrl_robosw_led_clk: robosw_led_clk { + function = "robosw_led_clk"; + pins = "gpio5"; +}; + +pinctrl_robosw_led0: robosw_led0 { + function = "robosw_led0"; + pins = "gpio6"; +}; + +pinctrl_robosw_led1: robosw_led1 { + function = "robosw_led1"; + pins = "gpio7"; +}; + +pinctrl_inet_led: inet_led { + function = "inet_led"; + pins = "gpio8"; +}; + +pinctrl_spi_cs2: spi_cs2 { + function = "spi_cs2"; + pins = "gpio9"; +}; + +pinctrl_spi_cs3: spi_cs3 { + function = "spi_cs3"; + pins = "gpio10"; +}; + +pinctrl_ntr_pulse: ntr_pulse { + function = "ntr_pulse"; + pins = "gpio11"; +}; + +pinctrl_uart1_scts: uart1_scts { + function = "uart1_scts"; + pins = "gpio12"; +}; + +pinctrl_uart1_srts: uart1_srts { + function = "uart1_srts"; + pins = "gpio13"; +}; + +pinctrl_uart1: uart1 { + pinctrl_uart1_sdin: uart1_sdin { +function = "uart1_sdin"; +pins = "gpio14"; + }; + + pinctrl_uart1_sdout: uart1_sdout { +function = "uart1_sdout"; +pins = "gpio15"; + }; +}; + +pinctrl_adsl_spi: adsl_spi { + pinctrl_adsl_spi_miso: adsl_spi_miso { +function = "adsl_spi_miso"; +
[PATCH v2 08/12] pinctrl: add a pincontrol driver for BCM6368
Add a pincontrol driver for BCM6368. BCM6368 allows muxing the first 32 GPIOs onto alternative functions. Not all are documented. Signed-off-by: Álvaro Fernández Rojas Signed-off-by: Jonas Gorski --- v2: switch to GPIO_REGMAP drivers/pinctrl/bcm/Kconfig | 11 + drivers/pinctrl/bcm/Makefile | 1 + drivers/pinctrl/bcm/pinctrl-bcm6368.c | 587 ++ 3 files changed, 599 insertions(+) create mode 100644 drivers/pinctrl/bcm/pinctrl-bcm6368.c diff --git a/drivers/pinctrl/bcm/Kconfig b/drivers/pinctrl/bcm/Kconfig index 3dcceba17cd1..3c8e1f6f7bcd 100644 --- a/drivers/pinctrl/bcm/Kconfig +++ b/drivers/pinctrl/bcm/Kconfig @@ -64,6 +64,17 @@ config PINCTRL_BCM6362 help Say Y here to enable the Broadcom BCM6362 GPIO driver. +config PINCTRL_BCM6368 + bool "Broadcom BCM6368 GPIO driver" + depends on OF_GPIO && (BMIPS_GENERIC || COMPILE_TEST) + select PINMUX + select PINCONF + select GENERIC_PINCONF + select MFD_SYSCON + default BMIPS_GENERIC + help + Say Y here to enable the Broadcom BCM6368 GPIO driver. + config PINCTRL_IPROC_GPIO bool "Broadcom iProc GPIO (with PINCONF) driver" depends on OF_GPIO && (ARCH_BCM_IPROC || COMPILE_TEST) diff --git a/drivers/pinctrl/bcm/Makefile b/drivers/pinctrl/bcm/Makefile index 0ade52a390cb..2d9c99a41c51 100644 --- a/drivers/pinctrl/bcm/Makefile +++ b/drivers/pinctrl/bcm/Makefile @@ -6,6 +6,7 @@ obj-$(CONFIG_PINCTRL_BCM2835) += pinctrl-bcm2835.o obj-$(CONFIG_PINCTRL_BCM6328) += pinctrl-bcm6328.o obj-$(CONFIG_PINCTRL_BCM6358) += pinctrl-bcm6358.o obj-$(CONFIG_PINCTRL_BCM6362) += pinctrl-bcm6362.o +obj-$(CONFIG_PINCTRL_BCM6368) += pinctrl-bcm6368.o obj-$(CONFIG_PINCTRL_IPROC_GPIO) += pinctrl-iproc-gpio.o obj-$(CONFIG_PINCTRL_CYGNUS_MUX) += pinctrl-cygnus-mux.o obj-$(CONFIG_PINCTRL_NS) += pinctrl-ns.o diff --git a/drivers/pinctrl/bcm/pinctrl-bcm6368.c b/drivers/pinctrl/bcm/pinctrl-bcm6368.c new file mode 100644 index ..2c19d9e73230 --- /dev/null +++ b/drivers/pinctrl/bcm/pinctrl-bcm6368.c @@ -0,0 +1,587 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Driver for BCM6368 GPIO unit (pinctrl + GPIO) + * + * Copyright (C) 2021 Álvaro Fernández Rojas + * Copyright (C) 2016 Jonas Gorski + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "../core.h" +#include "../pinctrl-utils.h" + +#define MODULE_NAME"bcm6368-pinctrl" +#define BCM6368_BANK_GPIOS 32 +#define BCM6368_NUM_GPIOS 38 + +#define BCM6368_DIROUT_REG 0x04 +#define BCM6368_DATA_REG 0x0c +#define BCM6368_MODE_REG 0x18 +#define BCM6368_BASEMODE_REG 0x38 +#define BCM6368_BASEMODE_MASK 0x7 +#define BCM6368_BASEMODE_GPIO 0x0 +#define BCM6368_BASEMODE_UART10x1 + +struct bcm6368_pingroup { + const char *name; + const unsigned * const pins; + const unsigned num_pins; +}; + +struct bcm6368_function { + const char *name; + const char * const *groups; + const unsigned num_groups; + + unsigned dir_out:16; + unsigned basemode:3; +}; + +struct bcm6368_pinctrl { + struct device *dev; + struct regmap *regs; + struct regmap_field *overlays; + + struct pinctrl_dev *pctl_dev; + struct gpio_chip *gpio_chip; + struct pinctrl_desc pctl_desc; + struct pinctrl_gpio_range gpio_range; +}; + +#define BCM6368_BASEMODE_PIN(a, b) \ + { \ + .number = a,\ + .name = b, \ + .drv_data = (void *)true\ + } + +static const struct pinctrl_pin_desc bcm6368_pins[] = { + PINCTRL_PIN(0, "gpio0"), + PINCTRL_PIN(1, "gpio1"), + PINCTRL_PIN(2, "gpio2"), + PINCTRL_PIN(3, "gpio3"), + PINCTRL_PIN(4, "gpio4"), + PINCTRL_PIN(5, "gpio5"), + PINCTRL_PIN(6, "gpio6"), + PINCTRL_PIN(7, "gpio7"), + PINCTRL_PIN(8, "gpio8"), + PINCTRL_PIN(9, "gpio9"), + PINCTRL_PIN(10, "gpio10"), + PINCTRL_PIN(11, "gpio11"), + PINCTRL_PIN(12, "gpio12"), + PINCTRL_PIN(13, "gpio13"), + PINCTRL_PIN(14, "gpio14"), + PINCTRL_PIN(15, "gpio15"), + PINCTRL_PIN(16, "gpio16"), + PINCTRL_PIN(17, "gpio17"), + PINCTRL_PIN(18, "gpio18"), + PINCTRL_PIN(19, "gpio19"), + PINCTRL_PIN(20, "gpio20"), + PINCTRL_PIN(21, "gpio21"), + PINCTRL_PIN(22, "gpio22"), + PINCTRL_PIN(23, "gpio23"), + PINCTRL_PIN(24, "gpio24"), + PINCTRL_PIN(25, "gpio25"), + PINCTRL_PIN(26, "gpio26"), + PINCTRL_PIN(27, "gpio27"), + PINCTRL_PIN(28, "gpio28"), + PINCTRL_PIN(29, "gpio29"), + BCM6368_BASEMODE_PIN(30, "gpio30"), + BCM6368_BASEMODE_PIN(31, "gpi
[PATCH v2 09/12] Documentation: add BCM63268 pincontroller binding documentation
Add binding documentation for the pincontrol core found in the BCM63268 family SoCs. Signed-off-by: Álvaro Fernández Rojas Signed-off-by: Jonas Gorski --- v2: remove interrupts .../pinctrl/brcm,bcm63268-pinctrl.yaml| 182 ++ 1 file changed, 182 insertions(+) create mode 100644 Documentation/devicetree/bindings/pinctrl/brcm,bcm63268-pinctrl.yaml diff --git a/Documentation/devicetree/bindings/pinctrl/brcm,bcm63268-pinctrl.yaml b/Documentation/devicetree/bindings/pinctrl/brcm,bcm63268-pinctrl.yaml new file mode 100644 index ..151aa36f539b --- /dev/null +++ b/Documentation/devicetree/bindings/pinctrl/brcm,bcm63268-pinctrl.yaml @@ -0,0 +1,182 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/pinctrl/brcm,bcm63268-pinctrl.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Broadcom BCM63268 pin controller + +maintainers: + - Álvaro Fernández Rojas + - Jonas Gorski + +description: |+ + The pin controller node should be the child of a syscon node. + + Refer to the the bindings described in + Documentation/devicetree/bindings/mfd/syscon.yaml + +properties: + compatible: +const: brcm,bcm63268-pinctrl + + gpio-controller: true + + '#gpio-cells': +description: + Specifies the pin number and flags, as defined in + include/dt-bindings/gpio/gpio.h +const: 2 + +patternProperties: + '^.*$': +if: + type: object +then: + properties: +function: + $ref: "/schemas/types.yaml#/definitions/string" + enum: [ serial_led_clk, serial_led_data, hsspi_cs4, hsspi_cs5, + hsspi_cs6, hsspi_cs7, adsl_spi_miso, adsl_spi_mosi, + vreq_clk, pcie_clkreq_b, robosw_led_clk, robosw_led_data, + nand, gpio35_alt, dectpd, vdsl_phy_override_0, + vdsl_phy_override_1, vdsl_phy_override_2, + vdsl_phy_override_3, dsl_gpio8, dsl_gpio9 ] + +pins: + $ref: "/schemas/types.yaml#/definitions/string" + enum: [ gpio0, gpio1, gpio16, gpio17, gpio8, gpio9, gpio18, gpio19, + gpio22, gpio23, gpio30, gpio31, nand_grp, gpio35 + dectpd_grp, vdsl_phy_override_0_grp, + vdsl_phy_override_1_grp, vdsl_phy_override_2_grp, + vdsl_phy_override_3_grp, dsl_gpio8, dsl_gpio9 ] + +required: + - compatible + - gpio-controller + - '#gpio-cells' + +additionalProperties: false + +examples: + - | +gpio@10c0 { + compatible = "syscon", "simple-mfd"; + reg = <0x10c0 0x80>; + + pinctrl: pinctrl { +compatible = "brcm,bcm63268-pinctrl"; + +gpio-controller; +#gpio-cells = <2>; + +pinctrl_serial_led: serial_led { + pinctrl_serial_led_clk: serial_led_clk { +function = "serial_led_clk"; +pins = "gpio0"; + }; + + pinctrl_serial_led_data: serial_led_data { +function = "serial_led_data"; +pins = "gpio1"; + }; +}; + +pinctrl_hsspi_cs4: hsspi_cs4 { + function = "hsspi_cs4"; + pins = "gpio16"; +}; + +pinctrl_hsspi_cs5: hsspi_cs5 { + function = "hsspi_cs5"; + pins = "gpio17"; +}; + +pinctrl_hsspi_cs6: hsspi_cs6 { + function = "hsspi_cs6"; + pins = "gpio8"; +}; + +pinctrl_hsspi_cs7: hsspi_cs7 { + function = "hsspi_cs7"; + pins = "gpio9"; +}; + +pinctrl_adsl_spi: adsl_spi { + pinctrl_adsl_spi_miso: adsl_spi_miso { +function = "adsl_spi_miso"; +pins = "gpio18"; + }; + + pinctrl_adsl_spi_mosi: adsl_spi_mosi { +function = "adsl_spi_mosi"; +pins = "gpio19"; + }; +}; + +pinctrl_vreq_clk: vreq_clk { + function = "vreq_clk"; + pins = "gpio22"; +}; + +pinctrl_pcie_clkreq_b: pcie_clkreq_b { + function = "pcie_clkreq_b"; + pins = "gpio23"; +}; + +pinctrl_robosw_led_clk: robosw_led_clk { + function = "robosw_led_clk"; + pins = "gpio30"; +}; + +pinctrl_robosw_led_data: robosw_led_data { + function = "robosw_led_data"; + pins = "gpio31"; +}; + +pinctrl_nand: nand { + function = "nand"; + group = "nand_grp"; +}; + +pinctrl_gpio35_alt: gpio35_alt { + function = "gpio35_alt"; + pin = "gpio35"; +}; + +pinctrl_dectpd: dectpd { + function = "dectpd"; + group = "dectpd_grp"; +}; + +pinctrl_vdsl_phy_override_0: vdsl_phy_override_0 { + function = "vdsl_phy_override_0"; + group = "vdsl_phy_override_0_grp"; +}; + +pinctrl_vdsl_phy_override_1: vdsl_phy_override_1 { + function = "vdsl_phy
[PATCH v2 10/12] pinctrl: add a pincontrol driver for BCM63268
Add a pincontrol driver for BCM63268. BCM63268 allows muxing GPIOs to different functions. Depending on the mux, these are either single pin configurations or whole pin groups. Signed-off-by: Álvaro Fernández Rojas Signed-off-by: Jonas Gorski --- v2: switch to GPIO_REGMAP drivers/pinctrl/bcm/Kconfig| 11 + drivers/pinctrl/bcm/Makefile | 1 + drivers/pinctrl/bcm/pinctrl-bcm63268.c | 726 + 3 files changed, 738 insertions(+) create mode 100644 drivers/pinctrl/bcm/pinctrl-bcm63268.c diff --git a/drivers/pinctrl/bcm/Kconfig b/drivers/pinctrl/bcm/Kconfig index 3c8e1f6f7bcd..e6b4f97e3366 100644 --- a/drivers/pinctrl/bcm/Kconfig +++ b/drivers/pinctrl/bcm/Kconfig @@ -75,6 +75,17 @@ config PINCTRL_BCM6368 help Say Y here to enable the Broadcom BCM6368 GPIO driver. +config PINCTRL_BCM63268 + bool "Broadcom BCM63268 GPIO driver" + depends on OF_GPIO && (BMIPS_GENERIC || COMPILE_TEST) + select PINMUX + select PINCONF + select GENERIC_PINCONF + select MFD_SYSCON + default BMIPS_GENERIC + help + Say Y here to enable the Broadcom BCM63268 GPIO driver. + config PINCTRL_IPROC_GPIO bool "Broadcom iProc GPIO (with PINCONF) driver" depends on OF_GPIO && (ARCH_BCM_IPROC || COMPILE_TEST) diff --git a/drivers/pinctrl/bcm/Makefile b/drivers/pinctrl/bcm/Makefile index 2d9c99a41c51..d5a8ee914fc6 100644 --- a/drivers/pinctrl/bcm/Makefile +++ b/drivers/pinctrl/bcm/Makefile @@ -7,6 +7,7 @@ obj-$(CONFIG_PINCTRL_BCM6328) += pinctrl-bcm6328.o obj-$(CONFIG_PINCTRL_BCM6358) += pinctrl-bcm6358.o obj-$(CONFIG_PINCTRL_BCM6362) += pinctrl-bcm6362.o obj-$(CONFIG_PINCTRL_BCM6368) += pinctrl-bcm6368.o +obj-$(CONFIG_PINCTRL_BCM63268) += pinctrl-bcm63268.o obj-$(CONFIG_PINCTRL_IPROC_GPIO) += pinctrl-iproc-gpio.o obj-$(CONFIG_PINCTRL_CYGNUS_MUX) += pinctrl-cygnus-mux.o obj-$(CONFIG_PINCTRL_NS) += pinctrl-ns.o diff --git a/drivers/pinctrl/bcm/pinctrl-bcm63268.c b/drivers/pinctrl/bcm/pinctrl-bcm63268.c new file mode 100644 index ..723e1703b574 --- /dev/null +++ b/drivers/pinctrl/bcm/pinctrl-bcm63268.c @@ -0,0 +1,726 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Driver for BCM63268 GPIO unit (pinctrl + GPIO) + * + * Copyright (C) 2021 Álvaro Fernández Rojas + * Copyright (C) 2016 Jonas Gorski + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "../core.h" +#include "../pinctrl-utils.h" + +#define MODULE_NAME"bcm63268-pinctrl" +#define BCM63268_BANK_GPIOS32 +#define BCM63268_NUM_GPIOS 52 +#define BCM63268_NUM_LEDS 24 + +#define BCM63268_DIROUT_REG0x04 +#define BCM63268_DATA_REG 0x0c +#define BCM63268_LED_REG 0x10 +#define BCM63268_MODE_REG 0x18 +#define BCM63268_CTRL_REG 0x1c +#define BCM63268_BASEMODE_REG 0x38 +#define BCM63268_BASEMODE_NANDBIT(2) /* GPIOs 2-7, 24-31 */ +#define BCM63268_BASEMODE_GPIO35 BIT(4) /* GPIO 35 */ +#define BCM63268_BASEMODE_DECTPD BIT(5) /* GPIOs 8/9 */ +#define BCM63268_BASEMODE_VDSL_PHY_0 BIT(6) /* GPIOs 10/11 */ +#define BCM63268_BASEMODE_VDSL_PHY_1 BIT(7) /* GPIOs 12/13 */ +#define BCM63268_BASEMODE_VDSL_PHY_2 BIT(8) /* GPIOs 24/25 */ +#define BCM63268_BASEMODE_VDSL_PHY_3 BIT(9) /* GPIOs 26/27 */ + +enum bcm63268_pinctrl_reg { + BCM63268_LEDCTRL, + BCM63268_MODE, + BCM63268_CTRL, + BCM63268_BASEMODE, +}; + +struct bcm63268_pingroup { + const char *name; + const unsigned * const pins; + const unsigned num_pins; +}; + +struct bcm63268_function { + const char *name; + const char * const *groups; + const unsigned num_groups; + + enum bcm63268_pinctrl_reg reg; + uint32_t mask; +}; + +struct bcm63268_pinctrl { + struct device *dev; + struct regmap *regs; + + struct pinctrl_dev *pctl_dev; + struct pinctrl_desc pctl_desc; + struct pinctrl_gpio_range gpio_range; +}; + +#define BCM63268_PIN(a, b, basemode) \ + { \ + .number = a,\ + .name = b, \ + .drv_data = (void *)(basemode) \ + } + +static const struct pinctrl_pin_desc bcm63268_pins[] = { + PINCTRL_PIN(0, "gpio0"), + PINCTRL_PIN(1, "gpio1"), + BCM63268_PIN(2, "gpio2", BCM63268_BASEMODE_NAND), + BCM63268_PIN(3, "gpio3", BCM63268_BASEMODE_NAND), + BCM63268_PIN(4, "gpio4", BCM63268_BASEMODE_NAND), + BCM63268_PIN(5, "gpio5", BCM63268_BASEMODE_NAND), + BCM63268_PIN(6, "gpio6", BCM63268_BASEMODE_NAND), + BCM63268_PIN(7, "gpio7", BCM63268_BASEMODE_NAND
[PATCH v2 12/12] pinctrl: add a pincontrol driver for BCM6318
Add a pincontrol driver for BCM6318. BCM6318 allows muxing most GPIOs to different functions. BCM6318 is similar to BCM6328 with the addition of a pad register, and the GPIO meaning of the mux register changes based on the GPIO number. Signed-off-by: Álvaro Fernández Rojas Signed-off-by: Jonas Gorski --- v2: switch to GPIO_REGMAP drivers/pinctrl/bcm/Kconfig | 11 + drivers/pinctrl/bcm/Makefile | 1 + drivers/pinctrl/bcm/pinctrl-bcm6318.c | 574 ++ 3 files changed, 586 insertions(+) create mode 100644 drivers/pinctrl/bcm/pinctrl-bcm6318.c diff --git a/drivers/pinctrl/bcm/Kconfig b/drivers/pinctrl/bcm/Kconfig index e6b4f97e3366..6b87c09a5a08 100644 --- a/drivers/pinctrl/bcm/Kconfig +++ b/drivers/pinctrl/bcm/Kconfig @@ -29,6 +29,17 @@ config PINCTRL_BCM2835 help Say Y here to enable the Broadcom BCM2835 GPIO driver. +config PINCTRL_BCM6318 + bool "Broadcom BCM6318 GPIO driver" + depends on OF_GPIO && (BMIPS_GENERIC || COMPILE_TEST) + select PINMUX + select PINCONF + select GENERIC_PINCONF + select MFD_SYSCON + default BMIPS_GENERIC + help + Say Y here to enable the Broadcom BCM6318 GPIO driver. + config PINCTRL_BCM6328 bool "Broadcom BCM6328 GPIO driver" depends on OF_GPIO && (BMIPS_GENERIC || COMPILE_TEST) diff --git a/drivers/pinctrl/bcm/Makefile b/drivers/pinctrl/bcm/Makefile index d5a8ee914fc6..50faf6b2a018 100644 --- a/drivers/pinctrl/bcm/Makefile +++ b/drivers/pinctrl/bcm/Makefile @@ -3,6 +3,7 @@ obj-$(CONFIG_PINCTRL_BCM281XX) += pinctrl-bcm281xx.o obj-$(CONFIG_PINCTRL_BCM2835) += pinctrl-bcm2835.o +obj-$(CONFIG_PINCTRL_BCM6318) += pinctrl-bcm6318.o obj-$(CONFIG_PINCTRL_BCM6328) += pinctrl-bcm6328.o obj-$(CONFIG_PINCTRL_BCM6358) += pinctrl-bcm6358.o obj-$(CONFIG_PINCTRL_BCM6362) += pinctrl-bcm6362.o diff --git a/drivers/pinctrl/bcm/pinctrl-bcm6318.c b/drivers/pinctrl/bcm/pinctrl-bcm6318.c new file mode 100644 index ..24a25ab482c7 --- /dev/null +++ b/drivers/pinctrl/bcm/pinctrl-bcm6318.c @@ -0,0 +1,574 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Driver for BCM6318 GPIO unit (pinctrl + GPIO) + * + * Copyright (C) 2021 Álvaro Fernández Rojas + * Copyright (C) 2016 Jonas Gorski + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "../core.h" +#include "../pinctrl-utils.h" + +#define MODULE_NAME"bcm6318-pinctrl" +#define BCM6318_BANK_GPIOS 32 +#define BCM6318_NUM_GPIOS 50 +#define BCM6318_NUM_MUX48 + +#define BCM6318_DIROUT_REG 0x04 +#define BCM6318_DATA_REG 0x0c +#define BCM6318_MODE_REG 0x18 +#define BCM6318_MUX_REG0x1c +#define BCM6318_PAD_REG0x54 + +struct bcm6318_pingroup { + const char *name; + const unsigned * const pins; + const unsigned num_pins; +}; + +struct bcm6318_function { + const char *name; + const char * const *groups; + const unsigned num_groups; + + unsigned mode_val:1; + unsigned mux_val:2; +}; + +struct bcm6318_pinctrl { + struct device *dev; + struct regmap *regs; + + struct pinctrl_dev *pctl_dev; + struct pinctrl_desc pctl_desc; + struct pinctrl_gpio_range gpio_range; +}; + +static const struct pinctrl_pin_desc bcm6318_pins[] = { + PINCTRL_PIN(0, "gpio0"), + PINCTRL_PIN(1, "gpio1"), + PINCTRL_PIN(2, "gpio2"), + PINCTRL_PIN(3, "gpio3"), + PINCTRL_PIN(4, "gpio4"), + PINCTRL_PIN(5, "gpio5"), + PINCTRL_PIN(6, "gpio6"), + PINCTRL_PIN(7, "gpio7"), + PINCTRL_PIN(8, "gpio8"), + PINCTRL_PIN(9, "gpio9"), + PINCTRL_PIN(10, "gpio10"), + PINCTRL_PIN(11, "gpio11"), + PINCTRL_PIN(12, "gpio12"), + PINCTRL_PIN(13, "gpio13"), + PINCTRL_PIN(14, "gpio14"), + PINCTRL_PIN(15, "gpio15"), + PINCTRL_PIN(16, "gpio16"), + PINCTRL_PIN(17, "gpio17"), + PINCTRL_PIN(18, "gpio18"), + PINCTRL_PIN(19, "gpio19"), + PINCTRL_PIN(20, "gpio20"), + PINCTRL_PIN(21, "gpio21"), + PINCTRL_PIN(22, "gpio22"), + PINCTRL_PIN(23, "gpio23"), + PINCTRL_PIN(24, "gpio24"), + PINCTRL_PIN(25, "gpio25"), + PINCTRL_PIN(26, "gpio26"), + PINCTRL_PIN(27, "gpio27"), + PINCTRL_PIN(28, "gpio28"), + PINCTRL_PIN(29, "gpio29"), + PINCTRL_PIN(30, "gpio30"), + PINCTRL_PIN(31, "gpio31"), + PINCTRL_PIN(32, "gpio32"), + PINCTRL_PIN(33, "gpio33"), + PINCTRL_PIN(34, "gpio34"), + PINCTRL_PIN(35, "gpio35"), + PINCTRL_PIN(36, "gpio36"), + PINCTRL_PIN(37, "gpio37"), + PINCTRL_PIN(38, "gpio38"), + PINCTRL_PIN(39, "gpio39"), + PINCTRL_PIN(40, "gpio40"), + PINCTRL_PIN(41, "gpio41"), + PINCTRL_PIN(42, "gpio42"), + PINCTRL_
[PATCH v2 11/12] Documentation: add BCM6318 pincontroller binding documentation
Add binding documentation for the pincontrol core found in BCM6318 SoCs. Signed-off-by: Álvaro Fernández Rojas Signed-off-by: Jonas Gorski --- v2: remove interrupts .../pinctrl/brcm,bcm6318-pinctrl.yaml | 161 ++ 1 file changed, 161 insertions(+) create mode 100644 Documentation/devicetree/bindings/pinctrl/brcm,bcm6318-pinctrl.yaml diff --git a/Documentation/devicetree/bindings/pinctrl/brcm,bcm6318-pinctrl.yaml b/Documentation/devicetree/bindings/pinctrl/brcm,bcm6318-pinctrl.yaml new file mode 100644 index ..d6fd8ab68180 --- /dev/null +++ b/Documentation/devicetree/bindings/pinctrl/brcm,bcm6318-pinctrl.yaml @@ -0,0 +1,161 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/pinctrl/brcm,bcm6318-pinctrl.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Broadcom BCM6318 pin controller + +maintainers: + - Álvaro Fernández Rojas + - Jonas Gorski + +description: |+ + The pin controller node should be the child of a syscon node. + + Refer to the the bindings described in + Documentation/devicetree/bindings/mfd/syscon.yaml + +properties: + compatible: +const: brcm,bcm6318-pinctrl + + gpio-controller: true + + '#gpio-cells': +description: + Specifies the pin number and flags, as defined in + include/dt-bindings/gpio/gpio.h +const: 2 + +patternProperties: + '^.*$': +if: + type: object +then: + properties: +function: + $ref: "/schemas/types.yaml#/definitions/string" + enum: [ ephy0_spd_led, ephy1_spd_led, ephy2_spd_led, ephy3_spd_led, + ephy0_act_led, ephy1_act_led, ephy2_act_led, ephy3_act_led, + serial_led_data, serial_led_clk, inet_act_led, inet_fail_led, + dsl_led, post_fail_led, wlan_wps_led, usb_pwron, + usb_device_led, usb_active ] + +pins: + $ref: "/schemas/types.yaml#/definitions/string" + enum: [ gpio0, gpio1, gpio2, gpio3, gpio4, gpio5, gpio6, gpio7, + gpio8, gpio9, gpio10, gpio11, gpio12, gpio13, gpio40 ] + +required: + - compatible + - gpio-controller + - '#gpio-cells' + +additionalProperties: false + +examples: + - | +gpio@1080 { + compatible = "syscon", "simple-mfd"; + reg = <0x1080 0x80>; + + pinctrl: pinctrl { +compatible = "brcm,bcm6318-pinctrl"; + +gpio-controller; +#gpio-cells = <2>; + +pinctrl_ephy0_spd_led: ephy0_spd_led { + function = "ephy0_spd_led"; + pins = "gpio0"; +}; + +pinctrl_ephy1_spd_led: ephy1_spd_led { + function = "ephy1_spd_led"; + pins = "gpio1"; +}; + +pinctrl_ephy2_spd_led: ephy2_spd_led { + function = "ephy2_spd_led"; + pins = "gpio2"; +}; + +pinctrl_ephy3_spd_led: ephy3_spd_led { + function = "ephy3_spd_led"; + pins = "gpio3"; +}; + +pinctrl_ephy0_act_led: ephy0_act_led { + function = "ephy0_act_led"; + pins = "gpio4"; +}; + +pinctrl_ephy1_act_led: ephy1_act_led { + function = "ephy1_act_led"; + pins = "gpio5"; +}; + +pinctrl_ephy2_act_led: ephy2_act_led { + function = "ephy2_act_led"; + pins = "gpio6"; +}; + +pinctrl_ephy3_act_led: ephy3_act_led { + function = "ephy3_act_led"; + pins = "gpio7"; +}; + +pinctrl_serial_led: serial_led { + pinctrl_serial_led_data: serial_led_data { +function = "serial_led_data"; +pins = "gpio6"; + }; + + pinctrl_serial_led_clk: serial_led_clk { +function = "serial_led_clk"; +pins = "gpio7"; + }; +}; + +pinctrl_inet_act_led: inet_act_led { + function = "inet_act_led"; + pins = "gpio8"; +}; + +pinctrl_inet_fail_led: inet_fail_led { + function = "inet_fail_led"; + pins = "gpio9"; +}; + +pinctrl_dsl_led: dsl_led { + function = "dsl_led"; + pins = "gpio10"; +}; + +pinctrl_post_fail_led: post_fail_led { + function = "post_fail_led"; + pins = "gpio11"; +}; + +pinctrl_wlan_wps_led: wlan_wps_led { + function = "wlan_wps_led"; + pins = "gpio12"; +}; + +pinctrl_usb_pwron: usb_pwron { + function = "usb_pwron"; + pins = "gpio13"; +}; + +pinctrl_usb_device_led: usb_device_led { + function = "usb_device_led"; + pins = "gpio13"; +}; + +pinctrl_usb_active: usb_active { + function = "usb_active"; + pins = "gpio40"; +}; + }; +}; -- 2.20.1
Re: [PATCH 01/13] rcu/nocb: Fix potential missed nocb_timer rearm
On Tue, Mar 02, 2021 at 01:34:44PM +0100, Frederic Weisbecker wrote: > On Mon, Mar 01, 2021 at 05:48:29PM -0800, Paul E. McKenney wrote: > > On Wed, Feb 24, 2021 at 11:06:06PM +0100, Frederic Weisbecker wrote: > > > On Wed, Feb 24, 2021 at 10:37:09AM -0800, Paul E. McKenney wrote: > > > > On Tue, Feb 23, 2021 at 01:09:59AM +0100, Frederic Weisbecker wrote: > > > > > Two situations can cause a missed nocb timer rearm: > > > > > > > > > > 1) rdp(CPU A) queues its nocb timer. The grace period elapses before > > > > >the timer get a chance to fire. The nocb_gp kthread is awaken by > > > > >rdp(CPU B). The nocb_cb kthread for rdp(CPU A) is awaken and > > > > >process the callbacks, again before the nocb_timer for CPU A get a > > > > >chance to fire. rdp(CPU A) queues a callback and wakes up nocb_gp > > > > >kthread, cancelling the pending nocb_timer without resetting the > > > > >corresponding nocb_defer_wakeup. > > > > > > > > As discussed offlist, expanding the above scenario results in this > > > > sequence of steps: > > > > I renumbered the CPUs, since the ->nocb_gp_kthread would normally be > > associated with CPU 0. If the first CPU to enqueue a callback was also > > CPU 0, nocb_gp_wait() might clear that CPU's ->nocb_defer_wakeup, which > > would prevent this scenario from playing out. (But admittedly only if > > some other CPU handled by this same ->nocb_gp_kthread used its bypass.) > > Ok good point. > > > > > > > 1. There are no callbacks queued for any CPU covered by CPU 0-2's > > > > ->nocb_gp_kthread. > > > > And ->nocb_gp_kthread is associated with CPU 0. > > > > > > 2. CPU 1 enqueues its first callback with interrupts disabled, and > > > > thus must defer awakening its ->nocb_gp_kthread. It therefore > > > > queues its rcu_data structure's ->nocb_timer. > > > > At this point, CPU 1's rdp->nocb_defer_wakeup is RCU_NOCB_WAKE. > > Right. > > > > > 7. The grace period ends, so rcu_gp_kthread awakens the > > > > ->nocb_gp_kthread, which in turn awakens both CPU 1's and > > > > CPU 2's ->nocb_cb_kthread. > > > > And then ->nocb_cb_kthread sleeps waiting for more callbacks. > > Yep > > > > I managed to recollect some pieces of my brain. So keep the above but > > > let's change the point 10: > > > > > > 10. CPU 1 enqueues its second callback, this time with interrupts > > > enabled so it can wake directly ->nocb_gp_kthread. > > > It does so with calling __wake_nocb_gp() which also cancels the > > > > wake_nocb_gp() in current -rcu, correct? > > Heh, right. > > > > > So far so good, but why isn't the timer still queued from back in step > > > > 2? > > > > What am I missing here? Either way, could you please update the commit > > > > logs to tell the full story? At some later time, you might be very > > > > happy that you did. ;-) > > > > > > > > > 2) The "nocb_bypass_timer" ends up calling wake_nocb_gp() which > > > > > deletes > > > > >the pending "nocb_timer" (note they are not the same timers) for > > > > > the > > > > >given rdp without resetting the matching state stored in nocb_defer > > > > >wakeup. > > > > Would like to similarly expand this one, or would you prefer to rest your > > case on Case 1) above? > > I was about to say that we can skip that one, the changelog will already be > big enough but the "Fixes:" tag refers to the second scenario, since it's the > oldest vulnerable commit AFAICS. > > > > > > Fixes: d1b222c6be1f (rcu/nocb: Add bypass callback queueing) OK, how about if I queue a temporary commit (shown below) that just calls out the first scenario so that I can start testing, and you get me more detail on the second scenario? I can then update the commit. Thanx, Paul commit 302fd54b9ae98f678624cbf9bf7a4ca88455a8f9 Author: Frederic Weisbecker Date: Tue Feb 23 01:09:59 2021 +0100 rcu/nocb: Fix missed nocb_timer requeue This sequence of events can lead to a failure to requeue a CPU's ->nocb_timer: 1. There are no callbacks queued for any CPU covered by CPU 0-2's ->nocb_gp_kthread. Note that ->nocb_gp_kthread is associated with CPU 0. 2. CPU 1 enqueues its first callback with interrupts disabled, and thus must defer awakening its ->nocb_gp_kthread. It therefore queues its rcu_data structure's ->nocb_timer. At this point, CPU 1's rdp->nocb_defer_wakeup is RCU_NOCB_WAKE. 3. CPU 2, which shares the same ->nocb_gp_kthread, also enqueues a callback, but with interrupts enabled, allowing it to directly awaken the ->nocb_gp_kthread. 4. The newly awakened ->nocb_gp_kthread associates both CPU 1's and CPU 2's callbacks with a future grace period and arranges
Re: [PATCH 5.10 000/658] 5.10.20-rc3 review
On Tue, Mar 02, 2021 at 08:03:15PM +0100, Greg Kroah-Hartman wrote: > On Tue, Mar 02, 2021 at 10:44:15AM -0800, Guenter Roeck wrote: > > On 3/2/21 4:38 AM, Greg Kroah-Hartman wrote: > > > This is the start of the stable review cycle for the 5.10.20 release. > > > There are 658 patches in this series, all will be posted as a response > > > to this one. If anyone has any issues with these being applied, please > > > let me know. > > > > > > Responses should be made by Thu, 04 Mar 2021 12:32:41 +. > > > Anything received after that time might be too late. > > > > > > > Building arm:allmodconfig ... failed > > -- > > Error log: > > drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c: In function 'mtk_aal_config': > > drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c:183:54: error: 'struct > > mtk_ddp_comp' has no member named 'dev' > > 183 | struct mtk_ddp_comp_dev *priv = dev_get_drvdata(comp->dev); > > | ^~ > > drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c:185:44: error: dereferencing > > pointer to incomplete type 'struct mtk_ddp_comp_dev' > > 185 | mtk_ddp_write(cmdq_pkt, w << 16 | h, &priv->cmdq_reg, priv->regs, > > DISP_AAL_SIZE); > > |^~ > > drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c:185:2: error: too many > > arguments to function 'mtk_ddp_write' > > 185 | mtk_ddp_write(cmdq_pkt, w << 16 | h, &priv->cmdq_reg, priv->regs, > > DISP_AAL_SIZE); > > | ^ > > drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c:89:6: note: declared here > >89 | void mtk_ddp_write(struct cmdq_pkt *cmdq_pkt, unsigned int value, > > | ^ > > make[5]: *** [drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.o] Error 1 > > make[4]: *** [drivers/gpu/drm/mediatek] Error 2 > > > > --- > > Building arm64:allmodconfig ... failed > > -- > > Error log: > > drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c: In function 'mtk_aal_config': > > drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c:183:54: error: 'struct > > mtk_ddp_comp' has no member named 'dev' > > 183 | struct mtk_ddp_comp_dev *priv = dev_get_drvdata(comp->dev); > > | ^~ > > drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c:185:44: error: dereferencing > > pointer to incomplete type 'struct mtk_ddp_comp_dev' > > 185 | mtk_ddp_write(cmdq_pkt, w << 16 | h, &priv->cmdq_reg, priv->regs, > > DISP_AAL_SIZE); > > |^~ > > drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c:185:2: error: too many > > arguments to function 'mtk_ddp_write' > > 185 | mtk_ddp_write(cmdq_pkt, w << 16 | h, &priv->cmdq_reg, priv->regs, > > DISP_AAL_SIZE); > > | ^ > > drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.c:89:6: note: declared here > >89 | void mtk_ddp_write(struct cmdq_pkt *cmdq_pkt, unsigned int value, > > | ^ > > make[5]: *** [drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.o] Error 1 > > > > > > The same problem also affects v5.11.y. > > > > Am I missing something here ? Why do I see that problem ? It seems to be > > very basic. > > You aren't the only one, I got an off-list response that this was seen > as well. Let me dig into it... Found it, am dropping the offending patch now. Should also affect 5.11.y too. Looks like I'll do a whole new round of -rcs for all queues now, this has been a rough cycle... greg k-h
Re: [PATCH] KVM: SVM: Clear the CR4 register on reset
On Tue, Mar 02, 2021, Babu Moger wrote: > This problem was reported on a SVM guest while executing kexec. > Kexec fails to load the new kernel when the PCID feature is enabled. > > When kexec starts loading the new kernel, it starts the process by > resetting the vCPU's and then bringing each vCPU online one by one. > The vCPU reset is supposed to reset all the register states before the > vCPUs are brought online. However, the CR4 register is not reset during > this process. If this register is already setup during the last boot, > all the flags can remain intact. The X86_CR4_PCIDE bit can only be > enabled in long mode. So, it must be enabled much later in SMP > initialization. Having the X86_CR4_PCIDE bit set during SMP boot can > cause a boot failures. > > Fix the issue by resetting the CR4 register in init_vmcb(). > > Signed-off-by: Babu Moger Cc: sta...@vger.kernel.org The bug goes back too far to have a meaningful Fixes. Reviewed-by: Sean Christopherson On a related topic, I think we can clean up the RESET/INIT flows by hoisting the common code into kvm_vcpu_reset(). That would also provide good motivation for removing the init_vmcb() call in svm_create_vcpu(), which is fully redundant with the call in svm_vcpu_reset(). I'll put that on the todo list.
Re: KASAN: use-after-free Read in cipso_v4_genopt
syzbot has found a reproducer for the following issue on: HEAD commit:7a7fd0de Merge branch 'kmap-conversion-for-5.12' of git://.. git tree: upstream console output: https://syzkaller.appspot.com/x/log.txt?x=13693866d0 kernel config: https://syzkaller.appspot.com/x/.config?x=779a2568b654c1c6 dashboard link: https://syzkaller.appspot.com/bug?extid=9ec037722d2603a9f52e compiler: Debian clang version 11.0.1-2 syz repro: https://syzkaller.appspot.com/x/repro.syz?x=1576737ad0 C reproducer: https://syzkaller.appspot.com/x/repro.c?x=107bdcead0 IMPORTANT: if you fix the issue, please add the following tag to the commit: Reported-by: syzbot+9ec037722d2603a9f...@syzkaller.appspotmail.com == BUG: KASAN: use-after-free in cipso_v4_genopt+0x1078/0x1700 net/ipv4/cipso_ipv4.c:1784 Read of size 1 at addr 8881437d5710 by task syz-executor557/8392 CPU: 1 PID: 8392 Comm: syz-executor557 Not tainted 5.12.0-rc1-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Call Trace: __dump_stack lib/dump_stack.c:79 [inline] dump_stack+0x125/0x19e lib/dump_stack.c:120 print_address_description+0x5f/0x3a0 mm/kasan/report.c:232 __kasan_report mm/kasan/report.c:399 [inline] kasan_report+0x15e/0x210 mm/kasan/report.c:416 cipso_v4_genopt+0x1078/0x1700 net/ipv4/cipso_ipv4.c:1784 cipso_v4_sock_setattr+0x7c/0x460 net/ipv4/cipso_ipv4.c:1866 netlbl_sock_setattr+0x28e/0x2f0 net/netlabel/netlabel_kapi.c:995 smack_netlbl_add security/smack/smack_lsm.c:2404 [inline] smack_socket_post_create+0x13b/0x280 security/smack/smack_lsm.c:2774 security_socket_post_create+0x6f/0xd0 security/security.c:2122 __sock_create+0x62f/0x8c0 net/socket.c:1424 sock_create net/socket.c:1459 [inline] __sys_socket+0xde/0x2d0 net/socket.c:1501 __do_sys_socket net/socket.c:1510 [inline] __se_sys_socket net/socket.c:1508 [inline] __x64_sys_socket+0x76/0x80 net/socket.c:1508 do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46 entry_SYSCALL_64_after_hwframe+0x44/0xae RIP: 0033:0x440999 Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 e1 14 00 00 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 c0 ff ff ff f7 d8 64 89 01 48 RSP: 002b:7ffcfe002d48 EFLAGS: 0246 ORIG_RAX: 0029 RAX: ffda RBX: b3fc RCX: 00440999 RDX: 0002 RSI: 0003 RDI: 0402 RBP: R08: 7ffcfe002ee8 R09: 7ffcfe002ee8 R10: 0012 R11: 0246 R12: 7ffcfe002d5c R13: 431bde82d7b634db R14: 004ae018 R15: 004004a0 Allocated by task 1: kasan_save_stack mm/kasan/common.c:38 [inline] kasan_set_track mm/kasan/common.c:46 [inline] set_alloc_info mm/kasan/common.c:427 [inline] kasan_kmalloc+0xc2/0xf0 mm/kasan/common.c:506 kasan_kmalloc include/linux/kasan.h:233 [inline] kmem_cache_alloc_trace+0x21b/0x340 mm/slub.c:2934 kmalloc include/linux/slab.h:554 [inline] smk_cipso_doi+0x1af/0x4e0 security/smack/smackfs.c:696 init_smk_fs+0xe2/0x24e security/smack/smackfs.c:3010 do_one_initcall+0x12b/0x310 init/main.c:1226 do_initcall_level+0x14a/0x1f5 init/main.c:1299 do_initcalls+0x4b/0x8c init/main.c:1315 kernel_init_freeable+0x2e3/0x406 init/main.c:1537 kernel_init+0xd/0x290 init/main.c:1424 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:294 Freed by task 0: kasan_save_stack mm/kasan/common.c:38 [inline] kasan_set_track+0x3d/0x70 mm/kasan/common.c:46 kasan_set_free_info+0x1f/0x40 mm/kasan/generic.c:357 kasan_slab_free+0x100/0x140 mm/kasan/common.c:360 kasan_slab_free include/linux/kasan.h:199 [inline] slab_free_hook mm/slub.c:1562 [inline] slab_free_freelist_hook+0x13a/0x200 mm/slub.c:1600 slab_free mm/slub.c:3161 [inline] kfree+0xcf/0x2b0 mm/slub.c:4213 rcu_do_batch kernel/rcu/tree.c:2559 [inline] rcu_core+0x7a0/0x1220 kernel/rcu/tree.c:2794 __do_softirq+0x318/0x714 kernel/softirq.c:345 Last potentially related work creation: kasan_save_stack+0x27/0x50 mm/kasan/common.c:38 kasan_record_aux_stack+0xee/0x120 mm/kasan/generic.c:345 __call_rcu kernel/rcu/tree.c:3039 [inline] call_rcu+0x12f/0x8a0 kernel/rcu/tree.c:3114 cipso_v4_doi_remove+0x2e2/0x310 net/ipv4/cipso_ipv4.c:531 netlbl_cipsov4_remove+0x219/0x390 net/netlabel/netlabel_cipso_v4.c:715 genl_family_rcv_msg_doit net/netlink/genetlink.c:739 [inline] genl_family_rcv_msg net/netlink/genetlink.c:783 [inline] genl_rcv_msg+0xe4e/0x1280 net/netlink/genetlink.c:800 netlink_rcv_skb+0x190/0x3a0 net/netlink/af_netlink.c:2502 genl_rcv+0x24/0x40 net/netlink/genetlink.c:811 netlink_unicast_kernel net/netlink/af_netlink.c:1312 [inline] netlink_unicast+0x786/0x940 net/netlink/af_netlink.c:1338 netlink_sendmsg+0x9ae/0xd50 net/netlink/af_netlink.c:1927 sock_sendmsg_nosec net/socket.c:654 [inline] sock_sendmsg net/socket.c:674 [inline] sys_sendmsg+0x519/0x800
Re: [PATCH AUTOSEL 5.10 050/217] rsi: Fix TX EAPOL packet handling against iwlwifi AP
On 12/23/20 3:13 AM, Sasha Levin wrote: Hello Sasha, From: Marek Vasut [ Upstream commit 65277100caa2f2c62b6f3c4648b90d6f0435f3bc ] In case RSI9116 SDIO WiFi operates in STA mode against Intel 9260 in AP mode, the association fails. The former is using wpa_supplicant during association, the later is set up using hostapd: [...] Was this patch possibly missed from 5.10.y ? Also, while at it, I think it might make sense to pick the following two patches as well, they dramatically reduce interrupt rate of the RSI WiFi device, so it stops overloading lower-end devices: 287431463e786 ("rsi: Move card interrupt handling to RX thread") abd131a19f6b8 ("rsi: Clean up loop in the interrupt handler")
Re: [PATCH] gpio: regmap: move struct gpio_regmap definition
Hi, Am 2021-03-02 19:14, schrieb Álvaro Fernández Rojas: El 02/03/2021 a las 19:10, Michael Walle escribió: Am 2021-03-02 19:06, schrieb Álvaro Fernández Rojas: struct gpio_regmap should be declared in gpio/regmap.h. This way other drivers can access the structure data when registering a gpio regmap controller. The intention was really to keep this private to the gpio-regmap driver. Why do you need to access to the properties? I'm trying to add support for bcm63xx pin controllers, and Linus suggested that I could use gpio regmap instead of adding duplicated code. nice! However, I need to access gpio_chip inside gpio_regmap to call pinctrl_add_gpio_range() with gpio_chip.base. Can't we add something to gpio-regmap.c which will (1) either call pinctrl_add_gpio_range(), just (2) return the struct gpio_chip* or (3) even only gpio_chip.base? I don't know how many sense (1) make and how reusable that code would be for other drivers, though. Linus? -michael
[PATCH 4.4 00/92] 4.4.259-rc2 review
This is the start of the stable review cycle for the 4.4.259 release. There are 92 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know. Responses should be made by Thu, 04 Mar 2021 19:25:07 +. Anything received after that time might be too late. The whole patch series can be found in one patch at: https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.4.259-rc2.gz or in the git tree and branch at: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-4.4.y and the diffstat can be found below. thanks, greg k-h - Pseudo-Shortlog of commits: Greg Kroah-Hartman Linux 4.4.259-rc2 Nikos Tsironis dm era: Update in-core bitset after committing the metadata Peter Zijlstra futex: Fix OWNER_DEAD fixup Nikos Tsironis dm era: only resize metadata in preresume Nikos Tsironis dm era: Reinitialize bitset cache before digesting a new writeset Nikos Tsironis dm era: Use correct value size in equality function of writeset tree Nikos Tsironis dm era: Fix bitset memory leaks Nikos Tsironis dm era: Verify the data block size hasn't changed Nikos Tsironis dm era: Recover committed writeset after crash Bob Peterson gfs2: Don't skip dlm unlock if glock has an lvb Al Viro sparc32: fix a user-triggerable oops in clear_user() Chao Yu f2fs: fix out-of-repair __setattr_copy() Maxim Kiselev gpio: pcf857x: Fix missing first interrupt Fangrui Song module: Ignore _GLOBAL_OFFSET_TABLE_ when warning for undefined symbols Dan Williams libnvdimm/dimm: Avoid race between probe and available_slots_show() Yoshihiro Shimoda usb: renesas_usbhs: Clear pipe running flag in usbhs_pkt_pop() Muchun Song mm: hugetlb: fix a race between freeing and dissolving the page Jiri Kosina floppy: reintroduce O_NDELAY fix Sean Christopherson x86/reboot: Force all cpus to exit VMX root if VMX is supported Martin Kaiser staging: rtl8188eu: Add Edimax EW-7811UN V2 to device table Sabyrzhan Tasbolatov drivers/misc/vmw_vmci: restrict too big queue size in qp_host_alloc_queue Josef Bacik btrfs: fix reloc root leak with 0 ref reloc roots on recovery Jarkko Sakkinen KEYS: trusted: Fix migratable=1 failing Thinh Nguyen usb: dwc3: gadget: Fix dep->interval for fullspeed interrupt Thinh Nguyen usb: dwc3: gadget: Fix setting of DEPCFG.bInterval_m1 Dan Carpenter USB: serial: mos7720: fix error code in mos7720_write() Dan Carpenter USB: serial: mos7840: fix error code in mos7840_write() Lech Perczak USB: serial: option: update interface mapping for ZTE P685M Marcos Paulo de Souza Input: i8042 - add ASUS Zenbook Flip to noselftest list Dan Carpenter Input: joydev - prevent potential read overflow in ioctl Olivier Crête Input: xpad - add support for PowerA Enhanced Wired Controller for Xbox Series X|S Mikulas Patocka blk-settings: align max_sectors on "logical_block_size" boundary Bart Van Assche block: Move SECTOR_SIZE and SECTOR_SHIFT definitions into Randy Dunlap scsi: bnx2fc: Fix Kconfig warning & CNIC build errors Maxime Ripard i2c: brcmstb: Fix brcmstd_send_i2c_cmd condition Miaohe Lin mm/hugetlb: fix potential double free in hugetlb_register_node() error path Miaohe Lin mm/memory.c: fix potential pte_unmap_unlock pte error Heiner Kallweit PCI: Align checking of syscall user config accessors Jorgen Hansen VMCI: Use set_page_dirty_lock() when unregistering guest memory Aswath Govindraju misc: eeprom_93xx46: Add module alias to avoid breaking support for non device tree users Aswath Govindraju misc: eeprom_93xx46: Fix module alias to enable module autoprobe Randy Dunlap sparc64: only select COMPAT_BINFMT_ELF if BINFMT_ELF is set Dan Carpenter Input: elo - fix an error code in elo_connect() Namhyung Kim perf test: Fix unaligned access in sample parsing test Adrian Hunter perf intel-pt: Fix missing CYC processing in PSB Nathan Lynch powerpc/pseries/dlpar: handle ibm, configure-connector delay status Dan Carpenter mfd: wm831x-auxadc: Prevent use after free in wm831x_auxadc_read_irq() Steven Rostedt (VMware) tracepoint: Do not fail unregistering a probe due to memory failure Uwe Kleine-König amba: Fix resource leak for drivers without .remove Vladimir Murzin ARM: 9046/1: decompressor: Do not clear SCTLR.nTLSMD for ARMv7+ cores Christophe JAILLET mmc: usdhi6rol0: Fix a resource leak in the error handling path of the probe Christophe Leroy powerpc/47x: Disable 256k page size Shay Drory IB/umad: Return EIO in case of when device disassociated Pan Bian isofs: release buffer head before return Pan Bian regulator: axp20x: Fix reference cout leak Tom Rix clocksource/drivers/mxs_timer: Add mis
[PATCH 4.9 000/134] 4.9.259-rc3 review
This is the start of the stable review cycle for the 4.9.259 release. There are 134 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know. Responses should be made by Thu, 04 Mar 2021 19:25:07 +. Anything received after that time might be too late. The whole patch series can be found in one patch at: https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.9.259-rc3.gz or in the git tree and branch at: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-4.9.y and the diffstat can be found below. thanks, greg k-h - Pseudo-Shortlog of commits: Greg Kroah-Hartman Linux 4.9.259-rc3 Nikos Tsironis dm era: Update in-core bitset after committing the metadata Jason A. Donenfeld net: icmp: pass zeroed opts from icmp{,v6}_ndo_send before sending Leon Romanovsky ipv6: silence compilation warning for non-IPV6 builds Eric Dumazet ipv6: icmp6: avoid indirect call for icmpv6_send() Jason A. Donenfeld sunvnet: use icmp_ndo_send helper Jason A. Donenfeld gtp: use icmp_ndo_send helper Jason A. Donenfeld icmp: allow icmpv6_ndo_send to work with CONFIG_IPV6=n Jason A. Donenfeld icmp: introduce helper for nat'd source address in network device context Thomas Gleixner futex: fix dead code in attach_to_pi_owner() Peter Zijlstra futex: Fix OWNER_DEAD fixup Nikos Tsironis dm era: only resize metadata in preresume Nikos Tsironis dm era: Reinitialize bitset cache before digesting a new writeset Nikos Tsironis dm era: Use correct value size in equality function of writeset tree Nikos Tsironis dm era: Fix bitset memory leaks Nikos Tsironis dm era: Verify the data block size hasn't changed Nikos Tsironis dm era: Recover committed writeset after crash Bob Peterson gfs2: Don't skip dlm unlock if glock has an lvb Al Viro sparc32: fix a user-triggerable oops in clear_user() Chao Yu f2fs: fix out-of-repair __setattr_copy() Maxim Kiselev gpio: pcf857x: Fix missing first interrupt Frank Li mmc: sdhci-esdhc-imx: fix kernel panic when remove module Fangrui Song module: Ignore _GLOBAL_OFFSET_TABLE_ when warning for undefined symbols Dan Williams libnvdimm/dimm: Avoid race between probe and available_slots_show() Yoshihiro Shimoda usb: renesas_usbhs: Clear pipe running flag in usbhs_pkt_pop() Muchun Song mm: hugetlb: fix a race between freeing and dissolving the page Pan Bian mtd: spi-nor: hisi-sfc: Put child node np on error path Jiri Kosina floppy: reintroduce O_NDELAY fix Sean Christopherson x86/reboot: Force all cpus to exit VMX root if VMX is supported Martin Kaiser staging: rtl8188eu: Add Edimax EW-7811UN V2 to device table Sabyrzhan Tasbolatov drivers/misc/vmw_vmci: restrict too big queue size in qp_host_alloc_queue Paul Cercueil seccomp: Add missing return in non-void function Filipe Manana btrfs: fix extent buffer leak on failure to copy root Josef Bacik btrfs: fix reloc root leak with 0 ref reloc roots on recovery Josef Bacik btrfs: abort the transaction if we fail to inc ref in btrfs_copy_root Jarkko Sakkinen KEYS: trusted: Fix migratable=1 failing Thinh Nguyen usb: dwc3: gadget: Fix dep->interval for fullspeed interrupt Thinh Nguyen usb: dwc3: gadget: Fix setting of DEPCFG.bInterval_m1 Dan Carpenter USB: serial: mos7720: fix error code in mos7720_write() Dan Carpenter USB: serial: mos7840: fix error code in mos7840_write() Paul Cercueil usb: musb: Fix runtime PM race in musb_queue_resume_work Lech Perczak USB: serial: option: update interface mapping for ZTE P685M Marcos Paulo de Souza Input: i8042 - add ASUS Zenbook Flip to noselftest list Dan Carpenter Input: joydev - prevent potential read overflow in ioctl Olivier Crête Input: xpad - add support for PowerA Enhanced Wired Controller for Xbox Series X|S jeffrey.lin Input: raydium_ts_i2c - do not send zero length Qinglang Miao ACPI: configfs: add missing check after configfs_register_default_group() Mikulas Patocka blk-settings: align max_sectors on "logical_block_size" boundary Randy Dunlap scsi: bnx2fc: Fix Kconfig warning & CNIC build errors Maxime Ripard i2c: brcmstb: Fix brcmstd_send_i2c_cmd condition Marc Zyngier arm64: Add missing ISB after invalidating TLB in __primary_switch Miaohe Lin mm/hugetlb: fix potential double free in hugetlb_register_node() error path Miaohe Lin mm/memory.c: fix potential pte_unmap_unlock pte error Dan Carpenter ocfs2: fix a use after free on error Chuhong Yuan net/mlx4_core: Add missed mlx4_free_cmd_mailbox() Slawomir Laba i40e: Fix flow for IPv6 next header (extension header) Konrad Dybcio drm/msm/dsi: Correct io_start for MSM8994 (20nm PHY) Heiner
[PATCH 4.14 000/175] 4.14.223-rc4 review
This is the start of the stable review cycle for the 4.14.223 release. There are 175 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know. Responses should be made by Thu, 04 Mar 2021 19:25:07 +. Anything received after that time might be too late. The whole patch series can be found in one patch at: https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.14.223-rc4.gz or in the git tree and branch at: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-4.14.y and the diffstat can be found below. thanks, greg k-h - Pseudo-Shortlog of commits: Greg Kroah-Hartman Linux 4.14.223-rc4 Nikos Tsironis dm era: Update in-core bitset after committing the metadata Jason A. Donenfeld net: icmp: pass zeroed opts from icmp{,v6}_ndo_send before sending Leon Romanovsky ipv6: silence compilation warning for non-IPV6 builds Eric Dumazet ipv6: icmp6: avoid indirect call for icmpv6_send() Jason A. Donenfeld sunvnet: use icmp_ndo_send helper Jason A. Donenfeld gtp: use icmp_ndo_send helper Jason A. Donenfeld icmp: allow icmpv6_ndo_send to work with CONFIG_IPV6=n Jason A. Donenfeld icmp: introduce helper for nat'd source address in network device context Nikos Tsironis dm era: only resize metadata in preresume Nikos Tsironis dm era: Reinitialize bitset cache before digesting a new writeset Nikos Tsironis dm era: Use correct value size in equality function of writeset tree Nikos Tsironis dm era: Fix bitset memory leaks Nikos Tsironis dm era: Verify the data block size hasn't changed Nikos Tsironis dm era: Recover committed writeset after crash Bob Peterson gfs2: Don't skip dlm unlock if glock has an lvb Al Viro sparc32: fix a user-triggerable oops in clear_user() Chao Yu f2fs: fix out-of-repair __setattr_copy() Muchun Song printk: fix deadlock when kernel panic Maxim Kiselev gpio: pcf857x: Fix missing first interrupt Frank Li mmc: sdhci-esdhc-imx: fix kernel panic when remove module Fangrui Song module: Ignore _GLOBAL_OFFSET_TABLE_ when warning for undefined symbols Dan Williams libnvdimm/dimm: Avoid race between probe and available_slots_show() Yoshihiro Shimoda usb: renesas_usbhs: Clear pipe running flag in usbhs_pkt_pop() Muchun Song mm: hugetlb: fix a race between freeing and dissolving the page Mike Kravetz hugetlb: fix copy_huge_page_from_user contig page struct assumption Pan Bian fs/affs: release old buffer head on error path Pan Bian mtd: spi-nor: hisi-sfc: Put child node np on error path Alexander Usyskin watchdog: mei_wdt: request stop on unregister He Zhe arm64: uprobe: Return EOPNOTSUPP for AARCH32 instruction probing Jiri Kosina floppy: reintroduce O_NDELAY fix Sean Christopherson x86/reboot: Force all cpus to exit VMX root if VMX is supported Martin Kaiser staging: rtl8188eu: Add Edimax EW-7811UN V2 to device table Sabyrzhan Tasbolatov drivers/misc/vmw_vmci: restrict too big queue size in qp_host_alloc_queue Paul Cercueil seccomp: Add missing return in non-void function Corentin Labbe crypto: sun4i-ss - handle BigEndian for cipher Corentin Labbe crypto: sun4i-ss - checking sg length is not sufficient Filipe Manana btrfs: fix extent buffer leak on failure to copy root Josef Bacik btrfs: fix reloc root leak with 0 ref reloc roots on recovery Josef Bacik btrfs: abort the transaction if we fail to inc ref in btrfs_copy_root Jarkko Sakkinen KEYS: trusted: Fix migratable=1 failing James Bottomley tpm_tis: Fix check_locality for correct locality acquisition PeiSen Hou ALSA: hda/realtek: modify EAPD in the ALC886 Thinh Nguyen usb: dwc3: gadget: Fix dep->interval for fullspeed interrupt Thinh Nguyen usb: dwc3: gadget: Fix setting of DEPCFG.bInterval_m1 Dan Carpenter USB: serial: mos7720: fix error code in mos7720_write() Dan Carpenter USB: serial: mos7840: fix error code in mos7840_write() Paul Cercueil usb: musb: Fix runtime PM race in musb_queue_resume_work Lech Perczak USB: serial: option: update interface mapping for ZTE P685M Marcos Paulo de Souza Input: i8042 - add ASUS Zenbook Flip to noselftest list Dan Carpenter Input: joydev - prevent potential read overflow in ioctl Olivier Crête Input: xpad - add support for PowerA Enhanced Wired Controller for Xbox Series X|S jeffrey.lin Input: raydium_ts_i2c - do not send zero length Jason Gerecke HID: wacom: Ignore attempts to overwrite the touch_max value from HID Qinglang Miao ACPI: configfs: add missing check after configfs_register_default_group() Rafael J. Wysocki ACPI: property: Fix fwnode string properties matching Mikulas Patocka blk-settings: align max_sectors on "lo
[PATCH 4.19 000/246] 4.19.178-rc4 review
This is the start of the stable review cycle for the 4.19.178 release. There are 246 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know. Responses should be made by Thu, 04 Mar 2021 19:25:07 +. Anything received after that time might be too late. The whole patch series can be found in one patch at: https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.19.178-rc4.gz or in the git tree and branch at: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-4.19.y and the diffstat can be found below. thanks, greg k-h - Pseudo-Shortlog of commits: Greg Kroah-Hartman Linux 4.19.178-rc4 Takeshi Misawa net: qrtr: Fix memory leak in qrtr_tun_open Nikos Tsironis dm era: Update in-core bitset after committing the metadata Jason A. Donenfeld net: icmp: pass zeroed opts from icmp{,v6}_ndo_send before sending Leon Romanovsky ipv6: silence compilation warning for non-IPV6 builds Eric Dumazet ipv6: icmp6: avoid indirect call for icmpv6_send() Jason A. Donenfeld xfrm: interface: use icmp_ndo_send helper Jason A. Donenfeld sunvnet: use icmp_ndo_send helper Jason A. Donenfeld gtp: use icmp_ndo_send helper Jason A. Donenfeld icmp: allow icmpv6_ndo_send to work with CONFIG_IPV6=n Jason A. Donenfeld icmp: introduce helper for nat'd source address in network device context Nikos Tsironis dm era: only resize metadata in preresume Nikos Tsironis dm era: Reinitialize bitset cache before digesting a new writeset Nikos Tsironis dm era: Use correct value size in equality function of writeset tree Nikos Tsironis dm era: Fix bitset memory leaks Nikos Tsironis dm era: Verify the data block size hasn't changed Nikos Tsironis dm era: Recover committed writeset after crash Mikulas Patocka dm: fix deadlock when swapping to encrypted device Bob Peterson gfs2: Don't skip dlm unlock if glock has an lvb Al Viro sparc32: fix a user-triggerable oops in clear_user() Chao Yu f2fs: fix out-of-repair __setattr_copy() Chen Yu cpufreq: intel_pstate: Get per-CPU max freq via MSR_HWP_CAPABILITIES if available Muchun Song printk: fix deadlock when kernel panic Maxim Kiselev gpio: pcf857x: Fix missing first interrupt Frank Li mmc: sdhci-esdhc-imx: fix kernel panic when remove module Fangrui Song module: Ignore _GLOBAL_OFFSET_TABLE_ when warning for undefined symbols Suzuki K Poulose arm64: Extend workaround for erratum 1024718 to all versions of Cortex-A55 Dan Williams libnvdimm/dimm: Avoid race between probe and available_slots_show() Mike Kravetz hugetlb: fix copy_huge_page_from_user contig page struct assumption NeilBrown x86: fix seq_file iteration for pat/memtype.c NeilBrown seq_file: document how per-entry resources are managed. Pan Bian fs/affs: release old buffer head on error path Pan Bian mtd: spi-nor: hisi-sfc: Put child node np on error path Alexander Usyskin watchdog: mei_wdt: request stop on unregister He Zhe arm64: uprobe: Return EOPNOTSUPP for AARCH32 instruction probing Jiri Kosina floppy: reintroduce O_NDELAY fix Sean Christopherson x86/reboot: Force all cpus to exit VMX root if VMX is supported Pavel Machek media: ipu3-cio2: Fix mbus_code processing in cio2_subdev_set_fmt() Martin Kaiser staging: rtl8188eu: Add Edimax EW-7811UN V2 to device table Amey Narkhede staging: gdm724x: Fix DMA from stack Ilya Lipnitskiy staging/mt7621-dma: mtk-hsdma.c->hsdma-mt7621.c Frank Wunderlich dts64: mt7622: fix slow sd card access Jiri Bohac pstore: Fix typo in compression option name Sabyrzhan Tasbolatov drivers/misc/vmw_vmci: restrict too big queue size in qp_host_alloc_queue Ricky Wu misc: rtsx: init of rts522a add OCP power off when no card is present Paul Cercueil seccomp: Add missing return in non-void function Corentin Labbe crypto: sun4i-ss - handle BigEndian for cipher Corentin Labbe crypto: sun4i-ss - checking sg length is not sufficient Ard Biesheuvel crypto: arm64/sha - add missing module aliases Filipe Manana btrfs: fix extent buffer leak on failure to copy root Josef Bacik btrfs: fix reloc root leak with 0 ref reloc roots on recovery Josef Bacik btrfs: abort the transaction if we fail to inc ref in btrfs_copy_root Jarkko Sakkinen KEYS: trusted: Fix migratable=1 failing James Bottomley tpm_tis: Clean up locality release James Bottomley tpm_tis: Fix check_locality for correct locality acquisition PeiSen Hou ALSA: hda/realtek: modify EAPD in the ALC886 Dan Carpenter USB: serial: mos7720: fix error code in mos7720_write() Dan Carpenter USB: serial: mos7840: fix error code in mos7840_write() Johan Hovold USB: serial: ftdi_sio: fix FTX
Re: KASAN: use-after-free Read in cipso_v4_genopt
On Tue, Mar 2, 2021 at 8:25 PM syzbot wrote: > > syzbot has found a reproducer for the following issue on: > > HEAD commit:7a7fd0de Merge branch 'kmap-conversion-for-5.12' of git://.. > git tree: upstream > console output: https://syzkaller.appspot.com/x/log.txt?x=13693866d0 > kernel config: https://syzkaller.appspot.com/x/.config?x=779a2568b654c1c6 > dashboard link: https://syzkaller.appspot.com/bug?extid=9ec037722d2603a9f52e > compiler: Debian clang version 11.0.1-2 > syz repro: https://syzkaller.appspot.com/x/repro.syz?x=1576737ad0 > C reproducer: https://syzkaller.appspot.com/x/repro.c?x=107bdcead0 This wasn't arranged :) But the reproducer indeed contains NLBL_CIPSOV4_C_REMOVE and is repeated in a loop... > IMPORTANT: if you fix the issue, please add the following tag to the commit: > Reported-by: syzbot+9ec037722d2603a9f...@syzkaller.appspotmail.com > > == > BUG: KASAN: use-after-free in cipso_v4_genopt+0x1078/0x1700 > net/ipv4/cipso_ipv4.c:1784 > Read of size 1 at addr 8881437d5710 by task syz-executor557/8392 > > CPU: 1 PID: 8392 Comm: syz-executor557 Not tainted 5.12.0-rc1-syzkaller #0 > Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS > Google 01/01/2011 > Call Trace: > __dump_stack lib/dump_stack.c:79 [inline] > dump_stack+0x125/0x19e lib/dump_stack.c:120 > print_address_description+0x5f/0x3a0 mm/kasan/report.c:232 > __kasan_report mm/kasan/report.c:399 [inline] > kasan_report+0x15e/0x210 mm/kasan/report.c:416 > cipso_v4_genopt+0x1078/0x1700 net/ipv4/cipso_ipv4.c:1784 > cipso_v4_sock_setattr+0x7c/0x460 net/ipv4/cipso_ipv4.c:1866 > netlbl_sock_setattr+0x28e/0x2f0 net/netlabel/netlabel_kapi.c:995 > smack_netlbl_add security/smack/smack_lsm.c:2404 [inline] > smack_socket_post_create+0x13b/0x280 security/smack/smack_lsm.c:2774 > security_socket_post_create+0x6f/0xd0 security/security.c:2122 > __sock_create+0x62f/0x8c0 net/socket.c:1424 > sock_create net/socket.c:1459 [inline] > __sys_socket+0xde/0x2d0 net/socket.c:1501 > __do_sys_socket net/socket.c:1510 [inline] > __se_sys_socket net/socket.c:1508 [inline] > __x64_sys_socket+0x76/0x80 net/socket.c:1508 > do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46 > entry_SYSCALL_64_after_hwframe+0x44/0xae > RIP: 0033:0x440999 > Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 e1 14 00 00 90 48 89 f8 48 89 f7 48 > 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 > 01 c3 48 c7 c1 c0 ff ff ff f7 d8 64 89 01 48 > RSP: 002b:7ffcfe002d48 EFLAGS: 0246 ORIG_RAX: 0029 > RAX: ffda RBX: b3fc RCX: 00440999 > RDX: 0002 RSI: 0003 RDI: 0402 > RBP: R08: 7ffcfe002ee8 R09: 7ffcfe002ee8 > R10: 0012 R11: 0246 R12: 7ffcfe002d5c > R13: 431bde82d7b634db R14: 004ae018 R15: 004004a0 > > Allocated by task 1: > kasan_save_stack mm/kasan/common.c:38 [inline] > kasan_set_track mm/kasan/common.c:46 [inline] > set_alloc_info mm/kasan/common.c:427 [inline] > kasan_kmalloc+0xc2/0xf0 mm/kasan/common.c:506 > kasan_kmalloc include/linux/kasan.h:233 [inline] > kmem_cache_alloc_trace+0x21b/0x340 mm/slub.c:2934 > kmalloc include/linux/slab.h:554 [inline] > smk_cipso_doi+0x1af/0x4e0 security/smack/smackfs.c:696 > init_smk_fs+0xe2/0x24e security/smack/smackfs.c:3010 > do_one_initcall+0x12b/0x310 init/main.c:1226 > do_initcall_level+0x14a/0x1f5 init/main.c:1299 > do_initcalls+0x4b/0x8c init/main.c:1315 > kernel_init_freeable+0x2e3/0x406 init/main.c:1537 > kernel_init+0xd/0x290 init/main.c:1424 > ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:294 > > Freed by task 0: > kasan_save_stack mm/kasan/common.c:38 [inline] > kasan_set_track+0x3d/0x70 mm/kasan/common.c:46 > kasan_set_free_info+0x1f/0x40 mm/kasan/generic.c:357 > kasan_slab_free+0x100/0x140 mm/kasan/common.c:360 > kasan_slab_free include/linux/kasan.h:199 [inline] > slab_free_hook mm/slub.c:1562 [inline] > slab_free_freelist_hook+0x13a/0x200 mm/slub.c:1600 > slab_free mm/slub.c:3161 [inline] > kfree+0xcf/0x2b0 mm/slub.c:4213 > rcu_do_batch kernel/rcu/tree.c:2559 [inline] > rcu_core+0x7a0/0x1220 kernel/rcu/tree.c:2794 > __do_softirq+0x318/0x714 kernel/softirq.c:345 > > Last potentially related work creation: > kasan_save_stack+0x27/0x50 mm/kasan/common.c:38 > kasan_record_aux_stack+0xee/0x120 mm/kasan/generic.c:345 > __call_rcu kernel/rcu/tree.c:3039 [inline] > call_rcu+0x12f/0x8a0 kernel/rcu/tree.c:3114 > cipso_v4_doi_remove+0x2e2/0x310 net/ipv4/cipso_ipv4.c:531 > netlbl_cipsov4_remove+0x219/0x390 net/netlabel/netlabel_cipso_v4.c:715 > genl_family_rcv_msg_doit net/netlink/genetlink.c:739 [inline] > genl_family_rcv_msg net/netlink/genetlink.c:783 [inline] > genl_rcv_msg+0xe4e/0x1280 net/netlink/genetlink.c:800 > netlink_rcv_skb+0x190/0x3a0 net/netlink/af_netlink.c:2502 >
[PATCH 5.4 000/337] 5.4.102-rc5 review
This is the start of the stable review cycle for the 5.4.102 release. There are 337 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know. Responses should be made by Thu, 04 Mar 2021 19:25:07 +. Anything received after that time might be too late. The whole patch series can be found in one patch at: https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.4.102-rc5.gz or in the git tree and branch at: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-5.4.y and the diffstat can be found below. thanks, greg k-h - Pseudo-Shortlog of commits: Greg Kroah-Hartman Linux 5.4.102-rc5 Takeshi Misawa net: qrtr: Fix memory leak in qrtr_tun_open Nikos Tsironis dm era: Update in-core bitset after committing the metadata Vlad Buslov net: sched: fix police ext initialization Jason A. Donenfeld net: icmp: pass zeroed opts from icmp{,v6}_ndo_send before sending Leon Romanovsky ipv6: silence compilation warning for non-IPV6 builds Eric Dumazet ipv6: icmp6: avoid indirect call for icmpv6_send() Jason A. Donenfeld xfrm: interface: use icmp_ndo_send helper Jason A. Donenfeld sunvnet: use icmp_ndo_send helper Jason A. Donenfeld gtp: use icmp_ndo_send helper Jason A. Donenfeld icmp: allow icmpv6_ndo_send to work with CONFIG_IPV6=n Jason A. Donenfeld icmp: introduce helper for nat'd source address in network device context Ville Syrjälä drm/i915: Reject 446-480MHz HDMI clock on GLK Nikos Tsironis dm era: only resize metadata in preresume Nikos Tsironis dm era: Reinitialize bitset cache before digesting a new writeset Nikos Tsironis dm era: Use correct value size in equality function of writeset tree Nikos Tsironis dm era: Fix bitset memory leaks Nikos Tsironis dm era: Verify the data block size hasn't changed Nikos Tsironis dm era: Recover committed writeset after crash Mikulas Patocka dm writecache: fix writing beyond end of underlying device when shrinking Mikulas Patocka dm: fix deadlock when swapping to encrypted device Andreas Gruenbacher gfs2: Recursive gfs2_quota_hold in gfs2_iomap_end Bob Peterson gfs2: Don't skip dlm unlock if glock has an lvb Masahisa Kojima spi: spi-synquacer: fix set_cs handling Al Viro sparc32: fix a user-triggerable oops in clear_user() Chao Yu f2fs: fix out-of-repair __setattr_copy() Johannes Berg um: mm: check more comprehensively for stub changes Cornelia Huck virtio/s390: implement virtio-ccw revision 2 correctly Heiko Carstens s390/vtime: fix inline assembly clobber list Chen Yu cpufreq: intel_pstate: Get per-CPU max freq via MSR_HWP_CAPABILITIES if available Muchun Song printk: fix deadlock when kernel panic Maxim Kiselev gpio: pcf857x: Fix missing first interrupt Subbaraman Narayanamurthy spmi: spmi-pmic-arb: Fix hw_irq overflow Christophe Leroy powerpc/32s: Add missing call to kuep_lock on syscall entry Frank Li mmc: sdhci-esdhc-imx: fix kernel panic when remove module Fangrui Song module: Ignore _GLOBAL_OFFSET_TABLE_ when warning for undefined symbols Sean Young media: smipcie: fix interrupt handling and IR timeout Suzuki K Poulose arm64: Extend workaround for erratum 1024718 to all versions of Cortex-A55 Mike Kravetz hugetlb: fix copy_huge_page_from_user contig page struct assumption Mike Kravetz hugetlb: fix update_and_free_page contig page struct assumption NeilBrown x86: fix seq_file iteration for pat/memtype.c NeilBrown seq_file: document how per-entry resources are managed. Pan Bian fs/affs: release old buffer head on error path Pan Bian mtd: spi-nor: hisi-sfc: Put child node np on error path Takahiro Kuwano mtd: spi-nor: core: Add erase size check for erase command initialization Takahiro Kuwano mtd: spi-nor: core: Fix erase type discovery for overlaid region Takahiro Kuwano mtd: spi-nor: sfdp: Fix wrong erase type bitmask for overlaid region Takahiro Kuwano mtd: spi-nor: sfdp: Fix last erase region marking Alexander Usyskin watchdog: mei_wdt: request stop on unregister Sai Prakash Ranjan watchdog: qcom: Remove incorrect usage of QCOM_WDT_ENABLE_IRQ He Zhe arm64: uprobe: Return EOPNOTSUPP for AARCH32 instruction probing qiuguorui1 arm64: kexec_file: fix memory leakage in create_dtb() when fdt_open_into() fails Jiri Kosina floppy: reintroduce O_NDELAY fix Frederic Weisbecker rcu/nocb: Perform deferred wake up before last idle's need_resched() check Frederic Weisbecker rcu: Pull deferred rcuog wake up to rcu_eqs_enter() callers Cédric Le Goater powerpc/prom: Fix "ibm,arch-vec-5-platform-support" scan Sean Christopherson x86/reboot: Force all cpus to exit VMX root if VMX is supported S
Re: [PATCH] KVM: SVM: Clear the CR4 register on reset
On 3/2/21 1:20 PM, Sean Christopherson wrote: > On Tue, Mar 02, 2021, Babu Moger wrote: >> This problem was reported on a SVM guest while executing kexec. >> Kexec fails to load the new kernel when the PCID feature is enabled. >> >> When kexec starts loading the new kernel, it starts the process by >> resetting the vCPU's and then bringing each vCPU online one by one. >> The vCPU reset is supposed to reset all the register states before the >> vCPUs are brought online. However, the CR4 register is not reset during >> this process. If this register is already setup during the last boot, >> all the flags can remain intact. The X86_CR4_PCIDE bit can only be >> enabled in long mode. So, it must be enabled much later in SMP >> initialization. Having the X86_CR4_PCIDE bit set during SMP boot can >> cause a boot failures. >> >> Fix the issue by resetting the CR4 register in init_vmcb(). >> >> Signed-off-by: Babu Moger > > Cc: sta...@vger.kernel.org > > The bug goes back too far to have a meaningful Fixes. > > Reviewed-by: Sean Christopherson Sean, Thanks > > > On a related topic, I think we can clean up the RESET/INIT flows by hoisting > the > common code into kvm_vcpu_reset(). That would also provide good motivation > for > removing the init_vmcb() call in svm_create_vcpu(), which is fully redundant > with the call in svm_vcpu_reset(). I'll put that on the todo list. Yes.Please.Thought about cleaning init_vmcb and svm_vcpu_reset little bit. That will require some more tests and review. We didn't want to delay the fix for that now. Thanks Babu
[PATCH 5.10 000/657] 5.10.20-rc4 review
This is the start of the stable review cycle for the 5.10.20 release. There are 657 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know. Responses should be made by Thu, 04 Mar 2021 19:25:07 +. Anything received after that time might be too late. The whole patch series can be found in one patch at: https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.10.20-rc4.gz or in the git tree and branch at: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-5.10.y and the diffstat can be found below. thanks, greg k-h - Pseudo-Shortlog of commits: Greg Kroah-Hartman Linux 5.10.20-rc4 Cong Wang net_sched: fix RTNL deadlock again caused by request_module() Takeshi Misawa net: qrtr: Fix memory leak in qrtr_tun_open Vlad Buslov net: sched: fix police ext initialization Jason A. Donenfeld wireguard: queueing: get rid of per-peer ring buffers Jason A. Donenfeld wireguard: selftests: test multiple parallel streams Jason A. Donenfeld net: icmp: pass zeroed opts from icmp{,v6}_ndo_send before sending Leon Romanovsky ipv6: silence compilation warning for non-IPV6 builds Sumit Garg kgdb: fix to kill breakpoints on initmem after boot Ville Syrjälä drm/i915: Reject 446-480MHz HDMI clock on GLK Nikos Tsironis dm era: only resize metadata in preresume Nikos Tsironis dm era: Reinitialize bitset cache before digesting a new writeset Nikos Tsironis dm era: Use correct value size in equality function of writeset tree Nikos Tsironis dm era: Fix bitset memory leaks Nikos Tsironis dm era: Verify the data block size hasn't changed Nikos Tsironis dm era: Update in-core bitset after committing the metadata Nikos Tsironis dm era: Recover committed writeset after crash Mikulas Patocka dm writecache: fix writing beyond end of underlying device when shrinking Mikulas Patocka dm writecache: return the exact table values that were set Mikulas Patocka dm writecache: fix performance degradation in ssd mode Jeffle Xu dm table: fix zoned iterate_devices based device capability checks Jeffle Xu dm table: fix DAX iterate_devices based device capability checks Jeffle Xu dm table: fix iterate_devices based device capability checks Mikulas Patocka dm: fix deadlock when swapping to encrypted device Andreas Gruenbacher gfs2: Recursive gfs2_quota_hold in gfs2_iomap_end Andreas Gruenbacher gfs2: Lock imbalance on error path in gfs2_recover_one Bob Peterson gfs2: Don't skip dlm unlock if glock has an lvb Bob Peterson gfs2: fix glock confusion in function signal_our_withdraw Masahisa Kojima spi: spi-synquacer: fix set_cs handling Rasmus Villemoes spi: fsl: invert spisel_boot signal on MPC8309 Al Viro sparc32: fix a user-triggerable oops in clear_user() Jaegeuk Kim f2fs: flush data when enabling checkpoint back Chao Yu f2fs: enforce the immutable flag on open files Chao Yu f2fs: fix out-of-repair __setattr_copy() Huacai Chen irqchip/loongson-pch-msi: Use bitmap_zalloc() to allocate bitmap Johannes Berg um: defer killing userspace on page table update failures Johannes Berg um: mm: check more comprehensively for stub changes Cornelia Huck virtio/s390: implement virtio-ccw revision 2 correctly Heiko Carstens s390/vtime: fix inline assembly clobber list Jens Axboe proc: don't allow async path resolution of /proc/thread-self components Chen Yu cpufreq: intel_pstate: Get per-CPU max freq via MSR_HWP_CAPABILITIES if available Rafael J. Wysocki cpufreq: intel_pstate: Change intel_pstate_get_hwp_max() argument Shawn Guo cpufreq: qcom-hw: drop devm_xxx() calls from init/exit hooks Viresh Kumar thermal: cpufreq_cooling: freq_qos_update_request() returns < 0 on error Chris Wilson kcmp: Support selection of SYS_kcmp without CHECKPOINT_RESTORE Shin'ichiro Kawasaki zonefs: Fix file size of zones in full condition Namjae Jeon exfat: fix shift-out-of-bounds in exfat_fill_super() Muchun Song printk: fix deadlock when kernel panic Tim Harvey mfd: gateworks-gsc: Fix interrupt type Maxim Kiselev gpio: pcf857x: Fix missing first interrupt Alexander Usyskin mei: me: add adler lake point LP DID Alexander Usyskin mei: me: add adler lake point S DID Tomas Winkler mei: me: emmitsburg workstation DID Alexander Usyskin mei: fix transfer over dma with extended header Subbaraman Narayanamurthy spmi: spmi-pmic-arb: Fix hw_irq overflow Christophe Leroy powerpc/32s: Add missing call to kuep_lock on syscall entry Hari Bathini powerpc/kexec_file: fix FDT size estimation for kdump kernel Christophe Leroy powerpc/32: Preserve cr1 in exception prolog stack check to fix build error Shirley H
[PATCH 5.11 000/773] 5.11.3-rc3 review
This is the start of the stable review cycle for the 5.11.3 release. There are 773 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know. Responses should be made by Thu, 04 Mar 2021 19:25:07 +. Anything received after that time might be too late. The whole patch series can be found in one patch at: https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.11.3-rc3.gz or in the git tree and branch at: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-5.11.y and the diffstat can be found below. thanks, greg k-h - Pseudo-Shortlog of commits: Greg Kroah-Hartman Linux 5.11.3-rc3 Cong Wang net_sched: fix RTNL deadlock again caused by request_module() Takeshi Misawa net: qrtr: Fix memory leak in qrtr_tun_open Vlad Buslov net: sched: fix police ext initialization Jason A. Donenfeld wireguard: queueing: get rid of per-peer ring buffers Jason A. Donenfeld wireguard: selftests: test multiple parallel streams Jason A. Donenfeld net: icmp: pass zeroed opts from icmp{,v6}_ndo_send before sending Leon Romanovsky ipv6: silence compilation warning for non-IPV6 builds Sumit Garg kgdb: fix to kill breakpoints on initmem after boot Ville Syrjälä drm/i915: Reject 446-480MHz HDMI clock on GLK Nikos Tsironis dm era: only resize metadata in preresume Nikos Tsironis dm era: Reinitialize bitset cache before digesting a new writeset Nikos Tsironis dm era: Use correct value size in equality function of writeset tree Nikos Tsironis dm era: Fix bitset memory leaks Nikos Tsironis dm era: Verify the data block size hasn't changed Nikos Tsironis dm era: Update in-core bitset after committing the metadata Nikos Tsironis dm era: Recover committed writeset after crash Mikulas Patocka dm writecache: fix writing beyond end of underlying device when shrinking Mikulas Patocka dm writecache: return the exact table values that were set Mikulas Patocka dm writecache: fix performance degradation in ssd mode Jeffle Xu dm table: fix zoned iterate_devices based device capability checks Jeffle Xu dm table: fix DAX iterate_devices based device capability checks Jeffle Xu dm table: fix iterate_devices based device capability checks Mikulas Patocka dm: fix deadlock when swapping to encrypted device Andreas Gruenbacher gfs2: Recursive gfs2_quota_hold in gfs2_iomap_end Andreas Gruenbacher gfs2: Lock imbalance on error path in gfs2_recover_one Bob Peterson gfs2: Don't skip dlm unlock if glock has an lvb Bob Peterson gfs2: fix glock confusion in function signal_our_withdraw Masahisa Kojima spi: spi-synquacer: fix set_cs handling Rasmus Villemoes spi: fsl: invert spisel_boot signal on MPC8309 Paul Cercueil perf stat: Use nftw() instead of ftw() Al Viro sparc32: fix a user-triggerable oops in clear_user() Ronnie Sahlberg cifs: fix handling of escaped ',' in the password mount argument Paulo Alcantara cifs: fix nodfs mount option Paulo Alcantara cifs: introduce helper for finding referral server to improve DFS target resolution Paulo Alcantara cifs: check all path components in resolved dfs target Paulo Alcantara cifs: fix DFS failover Jaegeuk Kim f2fs: flush data when enabling checkpoint back Chao Yu f2fs: enforce the immutable flag on open files Chao Yu f2fs: fix out-of-repair __setattr_copy() Huacai Chen irqchip/loongson-pch-msi: Use bitmap_zalloc() to allocate bitmap Johannes Berg um: defer killing userspace on page table update failures Johannes Berg um: mm: check more comprehensively for stub changes Cornelia Huck virtio/s390: implement virtio-ccw revision 2 correctly Heiko Carstens s390/vtime: fix inline assembly clobber list Jens Axboe proc: don't allow async path resolution of /proc/thread-self components Chen Yu cpufreq: intel_pstate: Get per-CPU max freq via MSR_HWP_CAPABILITIES if available Rafael J. Wysocki cpufreq: intel_pstate: Change intel_pstate_get_hwp_max() argument Shawn Guo cpufreq: qcom-hw: drop devm_xxx() calls from init/exit hooks Viresh Kumar thermal: cpufreq_cooling: freq_qos_update_request() returns < 0 on error Chris Wilson kcmp: Support selection of SYS_kcmp without CHECKPOINT_RESTORE Shin'ichiro Kawasaki zonefs: Fix file size of zones in full condition Namjae Jeon exfat: fix shift-out-of-bounds in exfat_fill_super() Muchun Song printk: fix deadlock when kernel panic Tim Harvey mfd: gateworks-gsc: Fix interrupt type Maxim Kiselev gpio: pcf857x: Fix missing first interrupt Alexander Usyskin mei: me: add adler lake point LP DID Alexander Usyskin mei: me: add adler lake point S DID Tomas Winkler mei: me: emmitsburg workstatio
Re: Build regressions/improvements in v5.12-rc1
On Mon, Mar 1, 2021 at 9:21 AM Geert Uytterhoeven wrote: > > On Mon, 1 Mar 2021, Geert Uytterhoeven wrote: > > Below is the list of build error/warning regressions/improvements in > > v5.12-rc1[1] compared to v5.11[2]. > > > > Summarized: > > - build errors: +2/-0 > > > [1] > > http://kisskb.ellerman.id.au/kisskb/branch/linus/head/fe07bfda2fb9cdef8a4d4008a409bb02f35f1bd8/ > > (all 192 configs) > > [2] > > http://kisskb.ellerman.id.au/kisskb/branch/linus/head/f40ddce88593482919761f74910f42f4b84c004b/ > > (all 192 configs) > > > > > > *** ERRORS *** > > > > 2 error regressions: > > + /kisskb/src/drivers/gpu/drm/amd/amdgpu/../display/dc/calcs/dcn_calcs.c: > > error: implicit declaration of function 'disable_kernel_vsx' > > [-Werror=implicit-function-declaration]: => 674:2 > > + /kisskb/src/drivers/gpu/drm/amd/amdgpu/../display/dc/calcs/dcn_calcs.c: > > error: implicit declaration of function 'enable_kernel_vsx' > > [-Werror=implicit-function-declaration]: => 638:2 > > powerpc-gcc4.9/ppc64_book3e_allmodconfig > > This was fixed in v5.11-rc1, but reappeared in v5.12-rc1? Do you know what fixed in for 5.11? I guess for PPC64 we depend on CONFIG_VSX? Alex > > Gr{oetje,eeting}s, > > Geert > > -- > Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- > ge...@linux-m68k.org > > In personal conversations with technical people, I call myself a hacker. But > when I'm talking to journalists I just say "programmer" or something like > that. > -- Linus Torvalds > ___ > amd-gfx mailing list > amd-...@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Re: [PATCH v2 6/7] cmdline: Gives architectures opportunity to use generically defined boot cmdline manipulation
Hi Christophe, I love your patch! Yet something to improve: [auto build test ERROR on powerpc/next] [also build test ERROR on robh/for-next linus/master v5.12-rc1 next-20210302] [cannot apply to mpe/next] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch] url: https://github.com/0day-ci/linux/commits/Christophe-Leroy/Improve-boot-command-line-handling/20210303-014039 base: https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git next config: sh-randconfig-s031-20210302 (attached as .config) compiler: sh4-linux-gcc (GCC) 9.3.0 reproduce: wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # apt-get install sparse # sparse version: v0.6.3-241-geaceeafa-dirty # https://github.com/0day-ci/linux/commit/edc3f8320d1dcb21a71e4cfdb26a3d2b64215c30 git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review Christophe-Leroy/Improve-boot-command-line-handling/20210303-014039 git checkout edc3f8320d1dcb21a71e4cfdb26a3d2b64215c30 # save the attached .config to linux build tree COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=sh If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot All errors (new ones prefixed by >>): arch/sh/Kconfig:760:warning: choice value used outside its choice group >> init/Kconfig:142:error: recursive dependency detected! init/Kconfig:142: choice contains symbol CMDLINE init/Kconfig:132: symbol CMDLINE depends on CMDLINE_EXTEND init/Kconfig:155: symbol CMDLINE_EXTEND is part of choice For a resolution refer to Documentation/kbuild/kconfig-language.rst subsection "Kconfig recursive dependency limitations" vim +142 init/Kconfig 103 104 config BROKEN 105 bool 106 107 config BROKEN_ON_SMP 108 bool 109 depends on BROKEN || !SMP 110 default y 111 112 config INIT_ENV_ARG_LIMIT 113 int 114 default 32 if !UML 115 default 128 if UML 116 help 117Maximum of each of the number of arguments and environment 118variables passed to init from the kernel command line. 119 120 config HAVE_CMDLINE 121 bool 122 123 config CMDLINE_BOOL 124 bool "Default bootloader kernel arguments" 125 depends on HAVE_CMDLINE 126 help 127On some platforms, there is currently no way for the boot loader to 128pass arguments to the kernel. For these platforms, you can supply 129some command-line options at build time by entering them here. In 130most cases you will need to specify the root device here. 131 132 config CMDLINE 133 string "Initial kernel command string" 134 depends on CMDLINE_BOOL 135 default DEFAULT_CMDLINE 136 help 137On some platforms, there is currently no way for the boot loader to 138pass arguments to the kernel. For these platforms, you can supply 139some command-line options at build time by entering them here. In 140most cases you will need to specify the root device here. 141 > 142 choice 143 prompt "Kernel command line type" if CMDLINE != "" 144 default CMDLINE_FROM_BOOTLOADER 145 help 146Selects the way you want to use the default kernel arguments. 147 --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-...@lists.01.org .config.gz Description: application/gzip
Re: [PATCH] mm: memcontrol: fix kernel stack account
On Tue 02-03-21 10:50:32, Roman Gushchin wrote: > On Tue, Mar 02, 2021 at 03:37:33PM +0800, Muchun Song wrote: > > The alloc_thread_stack_node() cannot guarantee that allocated stack pages > > are in the same node when CONFIG_VMAP_STACK. Because we do not specify > > __GFP_THISNODE to __vmalloc_node_range(). Fix it by caling > > mod_lruvec_page_state() for each page one by one. > > Hm, I actually wonder if it makes any sense to split the stack over multiple > nodes? Maybe we should fix this instead? While this is not really ideal I am not really sure it is an actual problem worth complicating the code. I am pretty sure this would grow into more tricky problem quite quickly (e.g. proper memory policy handling). -- Michal Hocko SUSE Labs
[PATCH 06/23] KVM: nSVM: do not mark all VMCB01 fields dirty on nested vmexit
Since L1 and L2 now use different VMCBs, most of the fields remain the same from one L1 run to the next. svm_set_cr0 and other functions called by nested_svm_vmexit already take care of clearing the corresponding clean bits; only the TSC offset is special. Signed-off-by: Paolo Bonzini --- arch/x86/kvm/svm/nested.c | 9 + 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/arch/x86/kvm/svm/nested.c b/arch/x86/kvm/svm/nested.c index f88d0614d9b8..4fc742ba1f1f 100644 --- a/arch/x86/kvm/svm/nested.c +++ b/arch/x86/kvm/svm/nested.c @@ -698,8 +698,11 @@ int nested_svm_vmexit(struct vcpu_svm *svm) svm_set_gif(svm, false); svm->vmcb->control.exit_int_info = 0; - svm->vmcb->control.tsc_offset = svm->vcpu.arch.tsc_offset = - svm->vcpu.arch.l1_tsc_offset; + svm->vcpu.arch.tsc_offset = svm->vcpu.arch.l1_tsc_offset; + if (svm->vmcb->control.tsc_offset != svm->vcpu.arch.tsc_offset) { + svm->vmcb->control.tsc_offset = svm->vcpu.arch.tsc_offset; + vmcb_mark_dirty(svm->vmcb, VMCB_INTERCEPTS); + } svm->nested.ctl.nested_cr3 = 0; @@ -717,8 +720,6 @@ int nested_svm_vmexit(struct vcpu_svm *svm) svm->vcpu.arch.dr7 = DR7_FIXED_1; kvm_update_dr7(&svm->vcpu); - vmcb_mark_all_dirty(svm->vmcb); - trace_kvm_nested_vmexit_inject(vmcb12->control.exit_code, vmcb12->control.exit_info_1, vmcb12->control.exit_info_2, -- 2.26.2
[PATCH 00/23] SVM queue for 5.13
This includes: - vmcb01/vmcb02 split. Unfortunately this is a wash in terms of nested vmexit speed, which I did not expect. However, keeping the code more in sync with VMX is useful anyway. - move common VMX/SVM emulation to x86.c (Sean) - support for vSPEC_CTRL (Babu) Paolo Babu Moger (1): x86/cpufeatures: Add the Virtual SPEC_CTRL feature Cathy Avery (3): KVM: SVM: Use a separate vmcb for the nested L2 guest KVM: nSVM: Track the physical cpu of the vmcb vmrun through the vmcb KVM: nSVM: Track the ASID generation of the vmcb vmrun through the vmcb Krish Sadhukhan (1): KVM: nSVM: Add missing checks for reserved bits to svm_set_nested_state() Maxim Levitsky (1): KVM: nSVM: always use vmcb01 to for vmsave/vmload of guest state Paolo Bonzini (8): KVM: nSVM: rename functions and variables according to vmcbXY nomenclature KVM: nSVM: do not copy vmcb01->control blindly to vmcb02->control KVM: nSVM: do not mark all VMCB01 fields dirty on nested vmexit KVM: nSVM: do not mark all VMCB02 fields dirty on nested vmexit KVM: nSVM: only copy L1 non-VMLOAD/VMSAVE data in svm_set_nested_state() KVM: SVM: merge update_cr0_intercept into svm_set_cr0 KVM: SVM: move VMLOAD/VMSAVE to C code KVM: SVM: Add support for Virtual SPEC_CTRL Sean Christopherson (9): KVM: x86: Move nVMX's consistency check macro to common code KVM: nSVM: Trace VM-Enter consistency check failures KVM: SVM: Pass struct kvm_vcpu to exit handlers (and many, many other places) KVM: nSVM: Add VMLOAD/VMSAVE helper to deduplicate code KVM: x86: Move XSETBV emulation to common code KVM: x86: Move trivial instruction-based exit handlers to common code KVM: x86: Move RDPMC emulation to common code KVM: SVM: Don't manually emulate RDPMC if nrips=0 KVM: SVM: Skip intercepted PAUSE instructions after emulation arch/x86/include/asm/cpufeatures.h | 1 + arch/x86/include/asm/kvm_host.h| 9 +- arch/x86/include/asm/svm.h | 4 +- arch/x86/kvm/svm/avic.c| 24 +- arch/x86/kvm/svm/nested.c | 409 -- arch/x86/kvm/svm/sev.c | 27 +- arch/x86/kvm/svm/svm.c | 843 ++--- arch/x86/kvm/svm/svm.h | 51 +- arch/x86/kvm/svm/vmenter.S | 14 +- arch/x86/kvm/vmx/nested.c | 8 +- arch/x86/kvm/vmx/vmx.c | 74 +-- arch/x86/kvm/x86.c | 62 ++- arch/x86/kvm/x86.h | 8 + 13 files changed, 777 insertions(+), 757 deletions(-) -- 2.26.2
[PATCH 03/23] KVM: nSVM: Track the ASID generation of the vmcb vmrun through the vmcb
From: Cathy Avery This patch moves the asid_generation from the vcpu to the vmcb in order to track the ASID generation that was active the last time the vmcb was run. If sd->asid_generation changes between two runs, the old ASID is invalid and must be changed. Suggested-by: Paolo Bonzini Signed-off-by: Cathy Avery Message-Id: <20210112164313.4204-3-cav...@redhat.com> Signed-off-by: Paolo Bonzini --- arch/x86/kvm/svm/svm.c | 21 +++-- arch/x86/kvm/svm/svm.h | 2 +- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index c35285c926e0..aa1baf646ff0 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -1227,7 +1227,7 @@ static void init_vmcb(struct vcpu_svm *svm) save->cr3 = 0; save->cr4 = 0; } - svm->asid_generation = 0; + svm->current_vmcb->asid_generation = 0; svm->asid = 0; svm->nested.vmcb12_gpa = 0; @@ -1309,13 +1309,6 @@ void svm_switch_vmcb(struct vcpu_svm *svm, struct kvm_vmcb_info *target_vmcb) svm->vmcb = target_vmcb->ptr; svm->vmcb_pa = target_vmcb->pa; - /* - * Workaround: we don't yet track the ASID generation - * that was active the last time target_vmcb was run. - */ - - svm->asid_generation = 0; - /* * Track the physical CPU the target_vmcb is running on * in order to mark the VMCB dirty if the cpu changes at @@ -1382,7 +1375,6 @@ static int svm_create_vcpu(struct kvm_vcpu *vcpu) if (vmsa_page) svm->vmsa = page_address(vmsa_page); - svm->asid_generation = 0; svm->guest_state_loaded = false; svm_switch_vmcb(svm, &svm->vmcb01); @@ -1864,7 +1856,7 @@ static void new_asid(struct vcpu_svm *svm, struct svm_cpu_data *sd) vmcb_mark_dirty(svm->vmcb, VMCB_ASID); } - svm->asid_generation = sd->asid_generation; + svm->current_vmcb->asid_generation = sd->asid_generation; svm->asid = sd->next_asid++; } @@ -3432,10 +3424,11 @@ static void pre_svm_run(struct vcpu_svm *svm) /* * If the previous vmrun of the vmcb occurred on * a different physical cpu then we must mark the vmcb dirty. -*/ +* and assign a new asid. + */ if (unlikely(svm->current_vmcb->cpu != svm->vcpu.cpu)) { - svm->asid_generation = 0; + svm->current_vmcb->asid_generation = 0; vmcb_mark_all_dirty(svm->vmcb); svm->current_vmcb->cpu = svm->vcpu.cpu; } @@ -3444,7 +3437,7 @@ static void pre_svm_run(struct vcpu_svm *svm) return pre_sev_run(svm, svm->vcpu.cpu); /* FIXME: handle wraparound of asid_generation */ - if (svm->asid_generation != sd->asid_generation) + if (svm->current_vmcb->asid_generation != sd->asid_generation) new_asid(svm, sd); } @@ -3668,7 +3661,7 @@ void svm_flush_tlb(struct kvm_vcpu *vcpu) if (static_cpu_has(X86_FEATURE_FLUSHBYASID)) svm->vmcb->control.tlb_ctl = TLB_CONTROL_FLUSH_ASID; else - svm->asid_generation--; + svm->current_vmcb->asid_generation--; } static void svm_flush_tlb_gva(struct kvm_vcpu *vcpu, gva_t gva) diff --git a/arch/x86/kvm/svm/svm.h b/arch/x86/kvm/svm/svm.h index a37281097751..993155195212 100644 --- a/arch/x86/kvm/svm/svm.h +++ b/arch/x86/kvm/svm/svm.h @@ -85,6 +85,7 @@ struct kvm_vmcb_info { struct vmcb *ptr; unsigned long pa; int cpu; + uint64_t asid_generation; }; struct svm_nested_state { @@ -114,7 +115,6 @@ struct vcpu_svm { struct kvm_vmcb_info *current_vmcb; struct svm_cpu_data *svm_data; u32 asid; - uint64_t asid_generation; uint64_t sysenter_esp; uint64_t sysenter_eip; uint64_t tsc_aux; -- 2.26.2
[PATCH 13/23] KVM: SVM: Pass struct kvm_vcpu to exit handlers (and many, many other places)
From: Sean Christopherson Refactor the svm_exit_handlers API to pass @vcpu instead of @svm to allow directly invoking common x86 exit handlers (in a future patch). Opportunistically convert an absurd number of instances of 'svm->vcpu' to direct uses of 'vcpu' to avoid pointless casting. No functional change intended. Signed-off-by: Sean Christopherson Message-Id: <20210205005750.3841462-4-sea...@google.com> Signed-off-by: Paolo Bonzini --- arch/x86/kvm/svm/avic.c | 24 +- arch/x86/kvm/svm/nested.c | 126 - arch/x86/kvm/svm/sev.c| 27 +- arch/x86/kvm/svm/svm.c| 563 +++--- arch/x86/kvm/svm/svm.h| 14 +- 5 files changed, 384 insertions(+), 370 deletions(-) diff --git a/arch/x86/kvm/svm/avic.c b/arch/x86/kvm/svm/avic.c index 78bdcfac4e40..cd0285f15a68 100644 --- a/arch/x86/kvm/svm/avic.c +++ b/arch/x86/kvm/svm/avic.c @@ -270,7 +270,7 @@ static int avic_init_backing_page(struct kvm_vcpu *vcpu) if (id >= AVIC_MAX_PHYSICAL_ID_COUNT) return -EINVAL; - if (!svm->vcpu.arch.apic->regs) + if (!vcpu->arch.apic->regs) return -EINVAL; if (kvm_apicv_activated(vcpu->kvm)) { @@ -281,7 +281,7 @@ static int avic_init_backing_page(struct kvm_vcpu *vcpu) return ret; } - svm->avic_backing_page = virt_to_page(svm->vcpu.arch.apic->regs); + svm->avic_backing_page = virt_to_page(vcpu->arch.apic->regs); /* Setting AVIC backing page address in the phy APIC ID table */ entry = avic_get_physical_id_entry(vcpu, id); @@ -315,15 +315,16 @@ static void avic_kick_target_vcpus(struct kvm *kvm, struct kvm_lapic *source, } } -int avic_incomplete_ipi_interception(struct vcpu_svm *svm) +int avic_incomplete_ipi_interception(struct kvm_vcpu *vcpu) { + struct vcpu_svm *svm = to_svm(vcpu); u32 icrh = svm->vmcb->control.exit_info_1 >> 32; u32 icrl = svm->vmcb->control.exit_info_1; u32 id = svm->vmcb->control.exit_info_2 >> 32; u32 index = svm->vmcb->control.exit_info_2 & 0xFF; - struct kvm_lapic *apic = svm->vcpu.arch.apic; + struct kvm_lapic *apic = vcpu->arch.apic; - trace_kvm_avic_incomplete_ipi(svm->vcpu.vcpu_id, icrh, icrl, id, index); + trace_kvm_avic_incomplete_ipi(vcpu->vcpu_id, icrh, icrl, id, index); switch (id) { case AVIC_IPI_FAILURE_INVALID_INT_TYPE: @@ -347,11 +348,11 @@ int avic_incomplete_ipi_interception(struct vcpu_svm *svm) * set the appropriate IRR bits on the valid target * vcpus. So, we just need to kick the appropriate vcpu. */ - avic_kick_target_vcpus(svm->vcpu.kvm, apic, icrl, icrh); + avic_kick_target_vcpus(vcpu->kvm, apic, icrl, icrh); break; case AVIC_IPI_FAILURE_INVALID_TARGET: WARN_ONCE(1, "Invalid IPI target: index=%u, vcpu=%d, icr=%#0x:%#0x\n", - index, svm->vcpu.vcpu_id, icrh, icrl); + index, vcpu->vcpu_id, icrh, icrl); break; case AVIC_IPI_FAILURE_INVALID_BACKING_PAGE: WARN_ONCE(1, "Invalid backing page\n"); @@ -539,8 +540,9 @@ static bool is_avic_unaccelerated_access_trap(u32 offset) return ret; } -int avic_unaccelerated_access_interception(struct vcpu_svm *svm) +int avic_unaccelerated_access_interception(struct kvm_vcpu *vcpu) { + struct vcpu_svm *svm = to_svm(vcpu); int ret = 0; u32 offset = svm->vmcb->control.exit_info_1 & AVIC_UNACCEL_ACCESS_OFFSET_MASK; @@ -550,7 +552,7 @@ int avic_unaccelerated_access_interception(struct vcpu_svm *svm) AVIC_UNACCEL_ACCESS_WRITE_MASK; bool trap = is_avic_unaccelerated_access_trap(offset); - trace_kvm_avic_unaccelerated_access(svm->vcpu.vcpu_id, offset, + trace_kvm_avic_unaccelerated_access(vcpu->vcpu_id, offset, trap, write, vector); if (trap) { /* Handling Trap */ @@ -558,7 +560,7 @@ int avic_unaccelerated_access_interception(struct vcpu_svm *svm) ret = avic_unaccel_trap_write(svm); } else { /* Handling Fault */ - ret = kvm_emulate_instruction(&svm->vcpu, 0); + ret = kvm_emulate_instruction(vcpu, 0); } return ret; @@ -572,7 +574,7 @@ int avic_init_vcpu(struct vcpu_svm *svm) if (!avic || !irqchip_in_kernel(vcpu->kvm)) return 0; - ret = avic_init_backing_page(&svm->vcpu); + ret = avic_init_backing_page(vcpu); if (ret) return ret; diff --git a/arch/x86/kvm/svm/nested.c b/arch/x86/kvm/svm/nested.c index 03a06f959bc8..7ed49d8cef5e 100644 --- a/arch/x86/kvm/svm/nested.c +++ b/arch/x86/kvm/svm/nested.c @@ -247,11 +247,9 @@ static bool nested_vmcb_check_controls(struct vmcb_control_are
Re: [PATCH v2 9/9] phy/drivers/stm32: Use HZ macros
On 24-02-21, 15:42, Daniel Lezcano wrote: > HZ unit conversion macros are available in units.h, use them and > remove the duplicate definition. > > Signed-off-by: Daniel Lezcano > --- > drivers/phy/st/phy-stm32-usbphyc.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/phy/st/phy-stm32-usbphyc.c > b/drivers/phy/st/phy-stm32-usbphyc.c > index a54317e96c41..02dd12bb4692 100644 > --- a/drivers/phy/st/phy-stm32-usbphyc.c > +++ b/drivers/phy/st/phy-stm32-usbphyc.c > @@ -14,6 +14,7 @@ > #include > #include > #include > +#include > > #define STM32_USBPHYC_PLL0x0 > #define STM32_USBPHYC_MISC 0x8 > @@ -48,7 +49,6 @@ static const char * const supplies_names[] = { > #define PLL_FVCO_MHZ 2880 > #define PLL_INFF_MIN_RATE_HZ 1920 > #define PLL_INFF_MAX_RATE_HZ 3840 > -#define HZ_PER_MHZ 100L I dont see this in units.h, can you send this once it is merged upstream -- ~Vinod
Re: [PATCH] ASoC: simple-card: Add dummy dai support simple sound card
On Fri, Feb 26, 2021 at 02:05:29PM +0800, Shengjiu Wang wrote: > On Thu, Feb 25, 2021 at 9:17 PM Mark Brown wrote: > > On Thu, Feb 25, 2021 at 08:08:32PM +0800, Shengjiu Wang wrote: > > > If sound card doesn't need specific codec device, just > > > dummy codec is enough, then we can link the dummy component > > > directly. > > This is a big red flag - what circumstances are these? If it's a simple > > CODEC with no control then the general approach is to provide a driver > > which announces the capabilities of the CODEC and can be bound to as > > normal, the dummy component should never actively be used. > For the DMIC, SPDIF, HDMI ARC device or other > similar device that there is no codec connected, then dummy codec is > just used for registering the sound card. There are logical CODECs there, and we already have devices set up for those (like dmic.c for example). All the above cases have at least some constraints from the spec for the interface. signature.asc Description: PGP signature
[PATCH 01/23] KVM: SVM: Use a separate vmcb for the nested L2 guest
From: Cathy Avery svm->vmcb will now point to a separate vmcb for L1 (not nested) or L2 (nested). The main advantages are removing get_host_vmcb and hsave, in favor of concepts that are shared with VMX. We don't need anymore to stash the L1 registers in hsave while L2 runs, but we need to copy the VMLOAD/VMSAVE registers from VMCB01 to VMCB02 and back. This more or less has the same cost, but code-wise nested_svm_vmloadsave can be reused. This patch omits several optimizations that are possible: - for simplicity there is some wholesale copying of vmcb.control areas which can go away. - we should be able to better use the VMCB01 and VMCB02 clean bits. - another possibility is to always use VMCB01 for VMLOAD and VMSAVE, thus avoiding the copy of VMLOAD/VMSAVE registers from VMCB01 to VMCB02 and back. Tested: kvm-unit-tests kvm self tests Loaded fedora nested guest on fedora Signed-off-by: Cathy Avery Message-Id: <20201011184818.3609-3-cav...@redhat.com> [Fix conflicts; keep VMCB02 G_PAT up to date whenever guest writes the PAT MSR; do not copy CR4 over from VMCB01 as it is not needed anymore; add a few more comments. - Paolo] Signed-off-by: Paolo Bonzini --- arch/x86/kvm/svm/nested.c | 160 +++--- arch/x86/kvm/svm/svm.c| 49 +--- arch/x86/kvm/svm/svm.h| 31 3 files changed, 135 insertions(+), 105 deletions(-) diff --git a/arch/x86/kvm/svm/nested.c b/arch/x86/kvm/svm/nested.c index 35891d9a1099..3bbb4acdf956 100644 --- a/arch/x86/kvm/svm/nested.c +++ b/arch/x86/kvm/svm/nested.c @@ -92,12 +92,12 @@ static unsigned long nested_svm_get_tdp_cr3(struct kvm_vcpu *vcpu) static void nested_svm_init_mmu_context(struct kvm_vcpu *vcpu) { struct vcpu_svm *svm = to_svm(vcpu); - struct vmcb *hsave = svm->nested.hsave; WARN_ON(mmu_is_nested(vcpu)); vcpu->arch.mmu = &vcpu->arch.guest_mmu; - kvm_init_shadow_npt_mmu(vcpu, X86_CR0_PG, hsave->save.cr4, hsave->save.efer, + kvm_init_shadow_npt_mmu(vcpu, X86_CR0_PG, svm->vmcb01.ptr->save.cr4, + svm->vmcb01.ptr->save.efer, svm->nested.ctl.nested_cr3); vcpu->arch.mmu->get_guest_pgd = nested_svm_get_tdp_cr3; vcpu->arch.mmu->get_pdptr = nested_svm_get_tdp_pdptr; @@ -123,7 +123,7 @@ void recalc_intercepts(struct vcpu_svm *svm) return; c = &svm->vmcb->control; - h = &svm->nested.hsave->control; + h = &svm->vmcb01.ptr->control; g = &svm->nested.ctl; for (i = 0; i < MAX_INTERCEPT; i++) @@ -386,8 +386,19 @@ static int nested_svm_load_cr3(struct kvm_vcpu *vcpu, unsigned long cr3, return 0; } +void nested_vmcb02_compute_g_pat(struct vcpu_svm *svm) +{ + if (!svm->nested.vmcb02.ptr) + return; + + /* FIXME: merge g_pat from vmcb01 and vmcb12. */ + svm->nested.vmcb02.ptr->save.g_pat = svm->vmcb01.ptr->save.g_pat; +} + static void nested_prepare_vmcb_save(struct vcpu_svm *svm, struct vmcb *vmcb12) { + nested_vmcb02_compute_g_pat(svm); + /* Load the nested guest state */ svm->vmcb->save.es = vmcb12->save.es; svm->vmcb->save.cs = vmcb12->save.cs; @@ -417,6 +428,9 @@ static void nested_prepare_vmcb_control(struct vcpu_svm *svm) { const u32 mask = V_INTR_MASKING_MASK | V_GIF_ENABLE_MASK | V_GIF_MASK; + /* FIXME: go through each field one by one. */ + svm->nested.vmcb02.ptr->control = svm->vmcb01.ptr->control; + if (nested_npt_enabled(svm)) nested_svm_init_mmu_context(&svm->vcpu); @@ -425,7 +439,7 @@ static void nested_prepare_vmcb_control(struct vcpu_svm *svm) svm->vmcb->control.int_ctl = (svm->nested.ctl.int_ctl & ~mask) | - (svm->nested.hsave->control.int_ctl & mask); + (svm->vmcb01.ptr->control.int_ctl & mask); svm->vmcb->control.virt_ext= svm->nested.ctl.virt_ext; svm->vmcb->control.int_vector = svm->nested.ctl.int_vector; @@ -468,7 +482,13 @@ int enter_svm_guest_mode(struct vcpu_svm *svm, u64 vmcb12_gpa, svm->nested.vmcb12_gpa = vmcb12_gpa; + + WARN_ON(svm->vmcb == svm->nested.vmcb02.ptr); + + nested_svm_vmloadsave(svm->vmcb01.ptr, svm->nested.vmcb02.ptr); load_nested_vmcb_control(svm, &vmcb12->control); + + svm_switch_vmcb(svm, &svm->nested.vmcb02); nested_prepare_vmcb_control(svm); nested_prepare_vmcb_save(svm, vmcb12); @@ -489,8 +509,6 @@ int nested_svm_vmrun(struct vcpu_svm *svm) { int ret; struct vmcb *vmcb12; - struct vmcb *hsave = svm->nested.hsave; - struct vmcb *vmcb = svm->vmcb; struct kvm_host_map map; u64 vmcb12_gpa; @@ -529,28 +547,17 @@ int nested_svm_vmrun(struct vcpu_svm *svm) kvm_clear_interrupt_queue(&svm->vcpu); /* -* Save the old vmcb, so we don't need
[PATCH 16/23] KVM: x86: Move trivial instruction-based exit handlers to common code
From: Sean Christopherson Move the trivial exit handlers, e.g. for instructions that KVM "emulates" as nops, to common x86 code. Assign the common handlers directly to the exit handler arrays and drop the vendor trampolines. Opportunistically use pr_warn_once() where appropriate. No functional change intended. Signed-off-by: Sean Christopherson Message-Id: <20210205005750.3841462-7-sea...@google.com> Signed-off-by: Paolo Bonzini --- arch/x86/include/asm/kvm_host.h | 5 ++ arch/x86/kvm/svm/svm.c | 90 + arch/x86/kvm/vmx/vmx.c | 53 +++ arch/x86/kvm/x86.c | 34 + 4 files changed, 59 insertions(+), 123 deletions(-) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index b396e854c7db..cd26756dc9c1 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -1514,6 +1514,11 @@ int kvm_get_msr(struct kvm_vcpu *vcpu, u32 index, u64 *data); int kvm_set_msr(struct kvm_vcpu *vcpu, u32 index, u64 data); int kvm_emulate_rdmsr(struct kvm_vcpu *vcpu); int kvm_emulate_wrmsr(struct kvm_vcpu *vcpu); +int kvm_emulate_as_nop(struct kvm_vcpu *vcpu); +int kvm_emulate_invd(struct kvm_vcpu *vcpu); +int kvm_emulate_mwait(struct kvm_vcpu *vcpu); +int kvm_handle_invalid_op(struct kvm_vcpu *vcpu); +int kvm_emulate_monitor(struct kvm_vcpu *vcpu); int kvm_fast_pio(struct kvm_vcpu *vcpu, int size, unsigned short port, int in); int kvm_emulate_cpuid(struct kvm_vcpu *vcpu); diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index fcea45f40d76..607d7698c7ea 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -2101,21 +2101,6 @@ static int intr_interception(struct kvm_vcpu *vcpu) return 1; } -static int nop_on_interception(struct kvm_vcpu *vcpu) -{ - return 1; -} - -static int halt_interception(struct kvm_vcpu *vcpu) -{ - return kvm_emulate_halt(vcpu); -} - -static int vmmcall_interception(struct kvm_vcpu *vcpu) -{ - return kvm_emulate_hypercall(vcpu); -} - static int vmload_vmsave_interception(struct kvm_vcpu *vcpu, bool vmload) { struct vcpu_svm *svm = to_svm(vcpu); @@ -2341,17 +2326,6 @@ static int skinit_interception(struct kvm_vcpu *vcpu) return 1; } -static int wbinvd_interception(struct kvm_vcpu *vcpu) -{ - return kvm_emulate_wbinvd(vcpu); -} - -static int rdpru_interception(struct kvm_vcpu *vcpu) -{ - kvm_queue_exception(vcpu, UD_VECTOR); - return 1; -} - static int task_switch_interception(struct kvm_vcpu *vcpu) { struct vcpu_svm *svm = to_svm(vcpu); @@ -2417,11 +2391,6 @@ static int task_switch_interception(struct kvm_vcpu *vcpu) has_error_code, error_code); } -static int cpuid_interception(struct kvm_vcpu *vcpu) -{ - return kvm_emulate_cpuid(vcpu); -} - static int iret_interception(struct kvm_vcpu *vcpu) { struct vcpu_svm *svm = to_svm(vcpu); @@ -2436,12 +2405,6 @@ static int iret_interception(struct kvm_vcpu *vcpu) return 1; } -static int invd_interception(struct kvm_vcpu *vcpu) -{ - /* Treat an INVD instruction as a NOP and just skip it. */ - return kvm_skip_emulated_instruction(vcpu); -} - static int invlpg_interception(struct kvm_vcpu *vcpu) { if (!static_cpu_has(X86_FEATURE_DECODEASSISTS)) @@ -2808,11 +2771,6 @@ static int svm_complete_emulated_msr(struct kvm_vcpu *vcpu, int err) return 1; } -static int rdmsr_interception(struct kvm_vcpu *vcpu) -{ - return kvm_emulate_rdmsr(vcpu); -} - static int svm_set_vm_cr(struct kvm_vcpu *vcpu, u64 data) { struct vcpu_svm *svm = to_svm(vcpu); @@ -2996,17 +2954,12 @@ static int svm_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr) return 0; } -static int wrmsr_interception(struct kvm_vcpu *vcpu) -{ - return kvm_emulate_wrmsr(vcpu); -} - static int msr_interception(struct kvm_vcpu *vcpu) { if (to_svm(vcpu)->vmcb->control.exit_info_1) - return wrmsr_interception(vcpu); + return kvm_emulate_wrmsr(vcpu); else - return rdmsr_interception(vcpu); + return kvm_emulate_rdmsr(vcpu); } static int interrupt_window_interception(struct kvm_vcpu *vcpu) @@ -3043,23 +2996,6 @@ static int pause_interception(struct kvm_vcpu *vcpu) return 1; } -static int nop_interception(struct kvm_vcpu *vcpu) -{ - return kvm_skip_emulated_instruction(vcpu); -} - -static int monitor_interception(struct kvm_vcpu *vcpu) -{ - printk_once(KERN_WARNING "kvm: MONITOR instruction emulated as NOP!\n"); - return nop_interception(vcpu); -} - -static int mwait_interception(struct kvm_vcpu *vcpu) -{ - printk_once(KERN_WARNING "kvm: MWAIT instruction emulated as NOP!\n"); - return nop_interception(vcpu); -} - static int invpcid_interception(struct kvm_vcpu *vcpu) { struct vcpu_svm *svm = to_svm(vcpu); @@ -3122,15
[PATCH 21/23] KVM: nSVM: always use vmcb01 to for vmsave/vmload of guest state
From: Maxim Levitsky This allows to avoid copying of these fields between vmcb01 and vmcb02 on nested guest entry/exit. Signed-off-by: Maxim Levitsky Signed-off-by: Paolo Bonzini --- arch/x86/kvm/svm/nested.c | 3 -- arch/x86/kvm/svm/svm.c| 70 --- 2 files changed, 36 insertions(+), 37 deletions(-) diff --git a/arch/x86/kvm/svm/nested.c b/arch/x86/kvm/svm/nested.c index 7ed49d8cef5e..cda0ed49d4cb 100644 --- a/arch/x86/kvm/svm/nested.c +++ b/arch/x86/kvm/svm/nested.c @@ -536,7 +536,6 @@ int enter_svm_guest_mode(struct kvm_vcpu *vcpu, u64 vmcb12_gpa, WARN_ON(svm->vmcb == svm->nested.vmcb02.ptr); - nested_svm_vmloadsave(svm->vmcb01.ptr, svm->nested.vmcb02.ptr); nested_load_control_from_vmcb12(svm, &vmcb12->control); svm_switch_vmcb(svm, &svm->nested.vmcb02); @@ -721,8 +720,6 @@ int nested_svm_vmexit(struct vcpu_svm *svm) vmcb12->control.pause_filter_thresh = svm->vmcb->control.pause_filter_thresh; - nested_svm_vmloadsave(svm->nested.vmcb02.ptr, svm->vmcb01.ptr); - svm_switch_vmcb(svm, &svm->vmcb01); /* diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index a0df44f6c239..b68f795db792 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -1587,16 +1587,17 @@ static void svm_clear_vintr(struct vcpu_svm *svm) static struct vmcb_seg *svm_seg(struct kvm_vcpu *vcpu, int seg) { struct vmcb_save_area *save = &to_svm(vcpu)->vmcb->save; + struct vmcb_save_area *save01 = &to_svm(vcpu)->vmcb01.ptr->save; switch (seg) { case VCPU_SREG_CS: return &save->cs; case VCPU_SREG_DS: return &save->ds; case VCPU_SREG_ES: return &save->es; - case VCPU_SREG_FS: return &save->fs; - case VCPU_SREG_GS: return &save->gs; + case VCPU_SREG_FS: return &save01->fs; + case VCPU_SREG_GS: return &save01->gs; case VCPU_SREG_SS: return &save->ss; - case VCPU_SREG_TR: return &save->tr; - case VCPU_SREG_LDTR: return &save->ldtr; + case VCPU_SREG_TR: return &save01->tr; + case VCPU_SREG_LDTR: return &save01->ldtr; } BUG(); return NULL; @@ -2650,24 +2651,24 @@ static int svm_get_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info) switch (msr_info->index) { case MSR_STAR: - msr_info->data = svm->vmcb->save.star; + msr_info->data = svm->vmcb01.ptr->save.star; break; #ifdef CONFIG_X86_64 case MSR_LSTAR: - msr_info->data = svm->vmcb->save.lstar; + msr_info->data = svm->vmcb01.ptr->save.lstar; break; case MSR_CSTAR: - msr_info->data = svm->vmcb->save.cstar; + msr_info->data = svm->vmcb01.ptr->save.cstar; break; case MSR_KERNEL_GS_BASE: - msr_info->data = svm->vmcb->save.kernel_gs_base; + msr_info->data = svm->vmcb01.ptr->save.kernel_gs_base; break; case MSR_SYSCALL_MASK: - msr_info->data = svm->vmcb->save.sfmask; + msr_info->data = svm->vmcb01.ptr->save.sfmask; break; #endif case MSR_IA32_SYSENTER_CS: - msr_info->data = svm->vmcb->save.sysenter_cs; + msr_info->data = svm->vmcb01.ptr->save.sysenter_cs; break; case MSR_IA32_SYSENTER_EIP: msr_info->data = svm->sysenter_eip; @@ -2852,32 +2853,32 @@ static int svm_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr) svm->virt_spec_ctrl = data; break; case MSR_STAR: - svm->vmcb->save.star = data; + svm->vmcb01.ptr->save.star = data; break; #ifdef CONFIG_X86_64 case MSR_LSTAR: - svm->vmcb->save.lstar = data; + svm->vmcb01.ptr->save.lstar = data; break; case MSR_CSTAR: - svm->vmcb->save.cstar = data; + svm->vmcb01.ptr->save.cstar = data; break; case MSR_KERNEL_GS_BASE: - svm->vmcb->save.kernel_gs_base = data; + svm->vmcb01.ptr->save.kernel_gs_base = data; break; case MSR_SYSCALL_MASK: - svm->vmcb->save.sfmask = data; + svm->vmcb01.ptr->save.sfmask = data; break; #endif case MSR_IA32_SYSENTER_CS: - svm->vmcb->save.sysenter_cs = data; + svm->vmcb01.ptr->save.sysenter_cs = data; break; case MSR_IA32_SYSENTER_EIP: svm->sysenter_eip = data; - svm->vmcb->save.sysenter_eip = data; + svm->vmcb01.ptr->save.sysenter_eip = data; break; case MSR_IA32_SYSENTER_ESP: svm->sysenter_esp = data; - svm->vmcb->save.sysenter_esp = data; + svm->vmc
[PATCH 17/23] KVM: x86: Move RDPMC emulation to common code
From: Sean Christopherson Move the entirety of the accelerated RDPMC emulation to x86.c, and assign the common handler directly to the exit handler array for VMX. SVM has bizarre nrips behavior that prevents it from directly invoking the common handler. The nrips goofiness will be addressed in a future patch. Signed-off-by: Sean Christopherson Message-Id: <20210205005750.3841462-8-sea...@google.com> Signed-off-by: Paolo Bonzini --- arch/x86/include/asm/kvm_host.h | 2 +- arch/x86/kvm/svm/svm.c | 5 + arch/x86/kvm/vmx/vmx.c | 10 +- arch/x86/kvm/x86.c | 15 --- 4 files changed, 11 insertions(+), 21 deletions(-) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index cd26756dc9c1..3f13e0a51499 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -1554,7 +1554,7 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr); unsigned long kvm_get_rflags(struct kvm_vcpu *vcpu); void kvm_set_rflags(struct kvm_vcpu *vcpu, unsigned long rflags); -bool kvm_rdpmc(struct kvm_vcpu *vcpu); +int kvm_emulate_rdpmc(struct kvm_vcpu *vcpu); void kvm_queue_exception(struct kvm_vcpu *vcpu, unsigned nr); void kvm_queue_exception_e(struct kvm_vcpu *vcpu, unsigned nr, u32 error_code); diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index 607d7698c7ea..8cb31603bce5 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -2426,13 +2426,10 @@ static int rsm_interception(struct kvm_vcpu *vcpu) static int rdpmc_interception(struct kvm_vcpu *vcpu) { - int err; - if (!nrips) return emulate_on_interception(vcpu); - err = kvm_rdpmc(vcpu); - return kvm_complete_insn_gp(vcpu, err); + return kvm_emulate_rdpmc(vcpu); } static bool check_selective_cr0_intercepted(struct kvm_vcpu *vcpu, diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index 83afedbdbfe1..908f7a8af064 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -5192,14 +5192,6 @@ static int handle_invlpg(struct kvm_vcpu *vcpu) return kvm_skip_emulated_instruction(vcpu); } -static int handle_rdpmc(struct kvm_vcpu *vcpu) -{ - int err; - - err = kvm_rdpmc(vcpu); - return kvm_complete_insn_gp(vcpu, err); -} - static int handle_apic_access(struct kvm_vcpu *vcpu) { if (likely(fasteoi)) { @@ -5622,7 +5614,7 @@ static int (*kvm_vmx_exit_handlers[])(struct kvm_vcpu *vcpu) = { [EXIT_REASON_HLT] = kvm_emulate_halt, [EXIT_REASON_INVD]= kvm_emulate_invd, [EXIT_REASON_INVLPG] = handle_invlpg, - [EXIT_REASON_RDPMC] = handle_rdpmc, + [EXIT_REASON_RDPMC] = kvm_emulate_rdpmc, [EXIT_REASON_VMCALL] = kvm_emulate_hypercall, [EXIT_REASON_VMCLEAR] = handle_vmx_instruction, [EXIT_REASON_VMLAUNCH]= handle_vmx_instruction, diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 90a35769951f..c1b7bdf47e7e 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -1195,20 +1195,21 @@ void kvm_get_dr(struct kvm_vcpu *vcpu, int dr, unsigned long *val) } EXPORT_SYMBOL_GPL(kvm_get_dr); -bool kvm_rdpmc(struct kvm_vcpu *vcpu) +int kvm_emulate_rdpmc(struct kvm_vcpu *vcpu) { u32 ecx = kvm_rcx_read(vcpu); u64 data; - int err; - err = kvm_pmu_rdpmc(vcpu, ecx, &data); - if (err) - return err; + if (kvm_pmu_rdpmc(vcpu, ecx, &data)) { + kvm_inject_gp(vcpu, 0); + return 1; + } + kvm_rax_write(vcpu, (u32)data); kvm_rdx_write(vcpu, data >> 32); - return err; + return kvm_skip_emulated_instruction(vcpu); } -EXPORT_SYMBOL_GPL(kvm_rdpmc); +EXPORT_SYMBOL_GPL(kvm_emulate_rdpmc); /* * List of msr numbers which we expose to userspace through KVM_GET_MSRS -- 2.26.2
[PATCH 15/23] KVM: x86: Move XSETBV emulation to common code
From: Sean Christopherson Move the entirety of XSETBV emulation to x86.c, and assign the function directly to both VMX's and SVM's exit handlers, i.e. drop the unnecessary trampolines. No functional change intended. Signed-off-by: Sean Christopherson Message-Id: <20210205005750.3841462-6-sea...@google.com> Signed-off-by: Paolo Bonzini --- arch/x86/include/asm/kvm_host.h | 2 +- arch/x86/kvm/svm/svm.c | 11 +-- arch/x86/kvm/vmx/vmx.c | 11 +-- arch/x86/kvm/x86.c | 13 - 4 files changed, 11 insertions(+), 26 deletions(-) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index 85ccbd4b7c52..b396e854c7db 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -1542,7 +1542,7 @@ void kvm_get_dr(struct kvm_vcpu *vcpu, int dr, unsigned long *val); unsigned long kvm_get_cr8(struct kvm_vcpu *vcpu); void kvm_lmsw(struct kvm_vcpu *vcpu, unsigned long msw); void kvm_get_cs_db_l_bits(struct kvm_vcpu *vcpu, int *db, int *l); -int kvm_set_xcr(struct kvm_vcpu *vcpu, u32 index, u64 xcr); +int kvm_emulate_xsetbv(struct kvm_vcpu *vcpu); int kvm_get_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr); int kvm_set_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr); diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index 5815fedf978e..fcea45f40d76 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -2346,15 +2346,6 @@ static int wbinvd_interception(struct kvm_vcpu *vcpu) return kvm_emulate_wbinvd(vcpu); } -static int xsetbv_interception(struct kvm_vcpu *vcpu) -{ - u64 new_bv = kvm_read_edx_eax(vcpu); - u32 index = kvm_rcx_read(vcpu); - - int err = kvm_set_xcr(vcpu, index, new_bv); - return kvm_complete_insn_gp(vcpu, err); -} - static int rdpru_interception(struct kvm_vcpu *vcpu) { kvm_queue_exception(vcpu, UD_VECTOR); @@ -3156,7 +3147,7 @@ static int (*const svm_exit_handlers[])(struct kvm_vcpu *vcpu) = { [SVM_EXIT_WBINVD] = wbinvd_interception, [SVM_EXIT_MONITOR] = monitor_interception, [SVM_EXIT_MWAIT]= mwait_interception, - [SVM_EXIT_XSETBV] = xsetbv_interception, + [SVM_EXIT_XSETBV] = kvm_emulate_xsetbv, [SVM_EXIT_RDPRU]= rdpru_interception, [SVM_EXIT_EFER_WRITE_TRAP] = efer_trap, [SVM_EXIT_CR0_WRITE_TRAP] = cr_trap, diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index 50810d471462..0df836897447 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -5216,15 +5216,6 @@ static int handle_wbinvd(struct kvm_vcpu *vcpu) return kvm_emulate_wbinvd(vcpu); } -static int handle_xsetbv(struct kvm_vcpu *vcpu) -{ - u64 new_bv = kvm_read_edx_eax(vcpu); - u32 index = kvm_rcx_read(vcpu); - - int err = kvm_set_xcr(vcpu, index, new_bv); - return kvm_complete_insn_gp(vcpu, err); -} - static int handle_apic_access(struct kvm_vcpu *vcpu) { if (likely(fasteoi)) { @@ -5686,7 +5677,7 @@ static int (*kvm_vmx_exit_handlers[])(struct kvm_vcpu *vcpu) = { [EXIT_REASON_APIC_WRITE] = handle_apic_write, [EXIT_REASON_EOI_INDUCED] = handle_apic_eoi_induced, [EXIT_REASON_WBINVD] = handle_wbinvd, - [EXIT_REASON_XSETBV] = handle_xsetbv, + [EXIT_REASON_XSETBV] = kvm_emulate_xsetbv, [EXIT_REASON_TASK_SWITCH] = handle_task_switch, [EXIT_REASON_MCE_DURING_VMENTRY] = handle_machine_check, [EXIT_REASON_GDTR_IDTR] = handle_desc, diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 1d2bc89431a2..8dc69ff3d205 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -984,14 +984,17 @@ static int __kvm_set_xcr(struct kvm_vcpu *vcpu, u32 index, u64 xcr) return 0; } -int kvm_set_xcr(struct kvm_vcpu *vcpu, u32 index, u64 xcr) +int kvm_emulate_xsetbv(struct kvm_vcpu *vcpu) { - if (static_call(kvm_x86_get_cpl)(vcpu) == 0) - return __kvm_set_xcr(vcpu, index, xcr); + if (static_call(kvm_x86_get_cpl)(vcpu) != 0 || + __kvm_set_xcr(vcpu, kvm_rcx_read(vcpu), kvm_read_edx_eax(vcpu))) { + kvm_inject_gp(vcpu, 0); + return 1; + } - return 1; + return kvm_skip_emulated_instruction(vcpu); } -EXPORT_SYMBOL_GPL(kvm_set_xcr); +EXPORT_SYMBOL_GPL(kvm_emulate_xsetbv); bool kvm_is_valid_cr4(struct kvm_vcpu *vcpu, unsigned long cr4) { -- 2.26.2
[PATCH 09/23] KVM: nSVM: Add missing checks for reserved bits to svm_set_nested_state()
From: Krish Sadhukhan The path for SVM_SET_NESTED_STATE needs to have the same checks for the CPU registers, as we have in the VMRUN path for a nested guest. This patch adds those missing checks to svm_set_nested_state(). Suggested-by: Sean Christopherson Signed-off-by: Krish Sadhukhan Message-Id: <20201006190654.32305-3-krish.sadhuk...@oracle.com> Signed-off-by: Paolo Bonzini --- arch/x86/kvm/svm/nested.c | 54 --- 1 file changed, 39 insertions(+), 15 deletions(-) diff --git a/arch/x86/kvm/svm/nested.c b/arch/x86/kvm/svm/nested.c index 585b5aa1914f..cadf776f58f7 100644 --- a/arch/x86/kvm/svm/nested.c +++ b/arch/x86/kvm/svm/nested.c @@ -246,29 +246,51 @@ static bool nested_vmcb_check_controls(struct vmcb_control_area *control) return true; } -static bool nested_vmcb_checks(struct vcpu_svm *svm, struct vmcb *vmcb12) +static bool nested_vmcb_check_cr3_cr4(struct vcpu_svm *svm, + struct vmcb_save_area *save) { struct kvm_vcpu *vcpu = &svm->vcpu; - bool vmcb12_lma; - if ((vmcb12->save.efer & EFER_SVME) == 0) + /* +* These checks are also performed by KVM_SET_SREGS, +* except that EFER.LMA is not checked by SVM against +* CR0.PG && EFER.LME. +*/ + if ((save->efer & EFER_LME) && (save->cr0 & X86_CR0_PG)) { + if (!(save->cr4 & X86_CR4_PAE) || !(save->cr0 & X86_CR0_PE) || + kvm_vcpu_is_illegal_gpa(vcpu, save->cr3)) + return false; + } + + return kvm_is_valid_cr4(&svm->vcpu, save->cr4); +} + +/* Common checks that apply to both L1 and L2 state. */ +static bool nested_vmcb_valid_sregs(struct vcpu_svm *svm, + struct vmcb_save_area *save) +{ + if (!(save->efer & EFER_SVME)) return false; - if (((vmcb12->save.cr0 & X86_CR0_CD) == 0) && (vmcb12->save.cr0 & X86_CR0_NW)) + if (((save->cr0 & X86_CR0_CD) == 0 && (save->cr0 & X86_CR0_NW)) || + (save->cr0 & ~0xULL)) return false; - if (!kvm_dr6_valid(vmcb12->save.dr6) || !kvm_dr7_valid(vmcb12->save.dr7)) + if (!kvm_dr6_valid(save->dr6) || !kvm_dr7_valid(save->dr7)) return false; - vmcb12_lma = (vmcb12->save.efer & EFER_LME) && (vmcb12->save.cr0 & X86_CR0_PG); + if (!nested_vmcb_check_cr3_cr4(svm, save)) + return false; - if (vmcb12_lma) { - if (!(vmcb12->save.cr4 & X86_CR4_PAE) || - !(vmcb12->save.cr0 & X86_CR0_PE) || - kvm_vcpu_is_illegal_gpa(vcpu, vmcb12->save.cr3)) - return false; - } - if (!kvm_is_valid_cr4(&svm->vcpu, vmcb12->save.cr4)) + if (!kvm_valid_efer(&svm->vcpu, save->efer)) + return false; + + return true; +} + +static bool nested_vmcb_checks(struct vcpu_svm *svm, struct vmcb *vmcb12) +{ + if (!nested_vmcb_valid_sregs(svm, &vmcb12->save)) return false; return nested_vmcb_check_controls(&vmcb12->control); @@ -1232,9 +1254,11 @@ static int svm_set_nested_state(struct kvm_vcpu *vcpu, /* * Validate host state saved from before VMRUN (see * nested_svm_check_permissions). -* TODO: validate reserved bits for all saved state. */ - if (!(save->cr0 & X86_CR0_PG)) + if (!(save->cr0 & X86_CR0_PG) || + !(save->cr0 & X86_CR0_PE) || + (save->rflags & X86_EFLAGS_VM) || + !nested_vmcb_valid_sregs(svm, save)) goto out_free; /* -- 2.26.2
[PATCH 07/23] KVM: nSVM: do not mark all VMCB02 fields dirty on nested vmexit
Since L1 and L2 now use different VMCBs, most of the fields remain the same in VMCB02 from one L2 run to the next. Since KVM itself is not looking at VMCB12's clean field, for now not much can be optimized. However, in the future we could avoid more copies if the VMCB12's SEG and DT sections are clean. Signed-off-by: Paolo Bonzini --- arch/x86/kvm/svm/nested.c | 18 -- 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/arch/x86/kvm/svm/nested.c b/arch/x86/kvm/svm/nested.c index 4fc742ba1f1f..945c2a48b591 100644 --- a/arch/x86/kvm/svm/nested.c +++ b/arch/x86/kvm/svm/nested.c @@ -404,24 +404,32 @@ static void nested_vmcb02_prepare_save(struct vcpu_svm *svm, struct vmcb *vmcb12 svm->vmcb->save.cs = vmcb12->save.cs; svm->vmcb->save.ss = vmcb12->save.ss; svm->vmcb->save.ds = vmcb12->save.ds; + svm->vmcb->save.cpl = vmcb12->save.cpl; + vmcb_mark_dirty(svm->vmcb, VMCB_SEG); + svm->vmcb->save.gdtr = vmcb12->save.gdtr; svm->vmcb->save.idtr = vmcb12->save.idtr; + vmcb_mark_dirty(svm->vmcb, VMCB_DT); + kvm_set_rflags(&svm->vcpu, vmcb12->save.rflags | X86_EFLAGS_FIXED); svm_set_efer(&svm->vcpu, vmcb12->save.efer); svm_set_cr0(&svm->vcpu, vmcb12->save.cr0); svm_set_cr4(&svm->vcpu, vmcb12->save.cr4); - svm->vmcb->save.cr2 = svm->vcpu.arch.cr2 = vmcb12->save.cr2; + + svm->vcpu.arch.cr2 = vmcb12->save.cr2; kvm_rax_write(&svm->vcpu, vmcb12->save.rax); kvm_rsp_write(&svm->vcpu, vmcb12->save.rsp); kvm_rip_write(&svm->vcpu, vmcb12->save.rip); /* In case we don't even reach vcpu_run, the fields are not updated */ + svm->vmcb->save.cr2 = svm->vcpu.arch.cr2; svm->vmcb->save.rax = vmcb12->save.rax; svm->vmcb->save.rsp = vmcb12->save.rsp; svm->vmcb->save.rip = vmcb12->save.rip; + svm->vmcb->save.dr7 = vmcb12->save.dr7 | DR7_FIXED_1; svm->vcpu.arch.dr6 = vmcb12->save.dr6 | DR6_ACTIVE_LOW; - svm->vmcb->save.cpl = vmcb12->save.cpl; + vmcb_mark_dirty(svm->vmcb, VMCB_DR); } static void nested_vmcb02_prepare_control(struct vcpu_svm *svm) @@ -473,12 +481,10 @@ static void nested_vmcb02_prepare_control(struct vcpu_svm *svm) enter_guest_mode(&svm->vcpu); /* -* Merge guest and host intercepts - must be called with vcpu in -* guest-mode to take affect here +* Merge guest and host intercepts - must be called with vcpu in +* guest-mode to take effect. */ recalc_intercepts(svm); - - vmcb_mark_all_dirty(svm->vmcb); } int enter_svm_guest_mode(struct vcpu_svm *svm, u64 vmcb12_gpa, -- 2.26.2
[PATCH 23/23] KVM: SVM: Add support for Virtual SPEC_CTRL
Newer AMD processors have a feature to virtualize the use of the SPEC_CTRL MSR. Presence of this feature is indicated via CPUID function 0x800A_EDX[20]: GuestSpecCtrl. Hypervisors are not required to enable this feature since it is automatically enabled on processors that support it. A hypervisor may wish to impose speculation controls on guest execution or a guest may want to impose its own speculation controls. Therefore, the processor implements both host and guest versions of SPEC_CTRL. When in host mode, the host SPEC_CTRL value is in effect and writes update only the host version of SPEC_CTRL. On a VMRUN, the processor loads the guest version of SPEC_CTRL from the VMCB. When the guest writes SPEC_CTRL, only the guest version is updated. On a VMEXIT, the guest version is saved into the VMCB and the processor returns to only using the host SPEC_CTRL for speculation control. The guest SPEC_CTRL is located at offset 0x2E0 in the VMCB. The effective SPEC_CTRL setting is the guest SPEC_CTRL setting or'ed with the hypervisor SPEC_CTRL setting. This allows the hypervisor to ensure a minimum SPEC_CTRL if desired. This support also fixes an issue where a guest may sometimes see an inconsistent value for the SPEC_CTRL MSR on processors that support this feature. With the current SPEC_CTRL support, the first write to SPEC_CTRL is intercepted and the virtualized version of the SPEC_CTRL MSR is not updated. When the guest reads back the SPEC_CTRL MSR, it will be 0x0, instead of the actual expected value. There isn’t a security concern here, because the host SPEC_CTRL value is or’ed with the Guest SPEC_CTRL value to generate the effective SPEC_CTRL value. KVM writes with the guest's virtualized SPEC_CTRL value to SPEC_CTRL MSR just before the VMRUN, so it will always have the actual value even though it doesn’t appear that way in the guest. The guest will only see the proper value for the SPEC_CTRL register if the guest was to write to the SPEC_CTRL register again. With Virtual SPEC_CTRL support, the save area spec_ctrl is properly saved and restored. So, the guest will always see the proper value when it is read back. Signed-off-by: Babu Moger Message-Id: <161188100955.28787.11816849358413330720.stgit@bmoger-ubuntu> Signed-off-by: Paolo Bonzini --- arch/x86/include/asm/svm.h | 4 +++- arch/x86/kvm/svm/nested.c | 15 +++ arch/x86/kvm/svm/svm.c | 26 +- 3 files changed, 39 insertions(+), 6 deletions(-) diff --git a/arch/x86/include/asm/svm.h b/arch/x86/include/asm/svm.h index 1c561945b426..772e60efe243 100644 --- a/arch/x86/include/asm/svm.h +++ b/arch/x86/include/asm/svm.h @@ -269,7 +269,9 @@ struct vmcb_save_area { * SEV-ES guests when referenced through the GHCB or for * saving to the host save area. */ - u8 reserved_7[80]; + u8 reserved_7[72]; + u32 spec_ctrl; /* Guest version of SPEC_CTRL at 0x2E0 */ + u8 reserved_7b[4]; u32 pkru; u8 reserved_7a[20]; u64 reserved_8; /* rax already available at 0x01f8 */ diff --git a/arch/x86/kvm/svm/nested.c b/arch/x86/kvm/svm/nested.c index cda0ed49d4cb..90a1704b5752 100644 --- a/arch/x86/kvm/svm/nested.c +++ b/arch/x86/kvm/svm/nested.c @@ -512,6 +512,18 @@ static void nested_vmcb02_prepare_control(struct vcpu_svm *svm) recalc_intercepts(svm); } +static void nested_svm_copy_common_state(struct vmcb *from_vmcb, struct vmcb *to_vmcb) +{ + /* +* Some VMCB state is shared between L1 and L2 and thus has to be +* moved at the time of nested vmrun and vmexit. +* +* VMLOAD/VMSAVE state would also belong in this category, but KVM +* always performs VMLOAD and VMSAVE from the VMCB01. +*/ + to_vmcb->save.spec_ctrl = from_vmcb->save.spec_ctrl; +} + int enter_svm_guest_mode(struct kvm_vcpu *vcpu, u64 vmcb12_gpa, struct vmcb *vmcb12) { @@ -536,6 +548,7 @@ int enter_svm_guest_mode(struct kvm_vcpu *vcpu, u64 vmcb12_gpa, WARN_ON(svm->vmcb == svm->nested.vmcb02.ptr); + nested_svm_copy_common_state(svm->vmcb01.ptr, svm->nested.vmcb02.ptr); nested_load_control_from_vmcb12(svm, &vmcb12->control); svm_switch_vmcb(svm, &svm->nested.vmcb02); @@ -720,6 +733,8 @@ int nested_svm_vmexit(struct vcpu_svm *svm) vmcb12->control.pause_filter_thresh = svm->vmcb->control.pause_filter_thresh; + nested_svm_copy_common_state(svm->nested.vmcb02.ptr, svm->vmcb01.ptr); + svm_switch_vmcb(svm, &svm->vmcb01); /* diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index b68f795db792..c4f2f2f6b945 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -1245,6 +1245,13 @@ static void init_vmcb(struct kvm_vcpu *vcpu) svm_check_invpcid(svm); + /* +* If the host supports V_SPEC_CTRL then disable the interception +* of MSR_IA32_SPEC_CTRL. +
[PATCH 14/23] KVM: nSVM: Add VMLOAD/VMSAVE helper to deduplicate code
From: Sean Christopherson Add another helper layer for VMLOAD+VMSAVE, the code is identical except for the one line that determines which VMCB is the source and which is the destination. No functional change intended. Signed-off-by: Sean Christopherson Message-Id: <20210205005750.3841462-5-sea...@google.com> Signed-off-by: Paolo Bonzini --- arch/x86/kvm/svm/svm.c | 37 - 1 file changed, 12 insertions(+), 25 deletions(-) diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index c2626babe575..5815fedf978e 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -2116,7 +2116,7 @@ static int vmmcall_interception(struct kvm_vcpu *vcpu) return kvm_emulate_hypercall(vcpu); } -static int vmload_interception(struct kvm_vcpu *vcpu) +static int vmload_vmsave_interception(struct kvm_vcpu *vcpu, bool vmload) { struct vcpu_svm *svm = to_svm(vcpu); struct vmcb *vmcb12; @@ -2137,37 +2137,24 @@ static int vmload_interception(struct kvm_vcpu *vcpu) ret = kvm_skip_emulated_instruction(vcpu); - nested_svm_vmloadsave(vmcb12, svm->vmcb); + if (vmload) + nested_svm_vmloadsave(vmcb12, svm->vmcb); + else + nested_svm_vmloadsave(svm->vmcb, vmcb12); + kvm_vcpu_unmap(vcpu, &map, true); return ret; } -static int vmsave_interception(struct kvm_vcpu *vcpu) +static int vmload_interception(struct kvm_vcpu *vcpu) { - struct vcpu_svm *svm = to_svm(vcpu); - struct vmcb *vmcb12; - struct kvm_host_map map; - int ret; - - if (nested_svm_check_permissions(vcpu)) - return 1; - - ret = kvm_vcpu_map(vcpu, gpa_to_gfn(svm->vmcb->save.rax), &map); - if (ret) { - if (ret == -EINVAL) - kvm_inject_gp(vcpu, 0); - return 1; - } - - vmcb12 = map.hva; - - ret = kvm_skip_emulated_instruction(vcpu); - - nested_svm_vmloadsave(svm->vmcb, vmcb12); - kvm_vcpu_unmap(vcpu, &map, true); + return vmload_vmsave_interception(vcpu, true); +} - return ret; +static int vmsave_interception(struct kvm_vcpu *vcpu) +{ + return vmload_vmsave_interception(vcpu, false); } static int vmrun_interception(struct kvm_vcpu *vcpu) -- 2.26.2
[PATCH 10/23] KVM: x86: Move nVMX's consistency check macro to common code
From: Sean Christopherson Move KVM's CC() macro to x86.h so that it can be reused by nSVM. Debugging VM-Enter is as painful on SVM as it is on VMX. Rename the more visible macro to KVM_NESTED_VMENTER_CONSISTENCY_CHECK to avoid any collisions with the uber-concise "CC". Signed-off-by: Sean Christopherson Message-Id: <20210204000117.3303214-12-sea...@google.com> Signed-off-by: Paolo Bonzini --- arch/x86/kvm/vmx/nested.c | 8 +--- arch/x86/kvm/x86.h| 8 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c index bcca0b80e0d0..fdd80dd8e781 100644 --- a/arch/x86/kvm/vmx/nested.c +++ b/arch/x86/kvm/vmx/nested.c @@ -21,13 +21,7 @@ module_param_named(enable_shadow_vmcs, enable_shadow_vmcs, bool, S_IRUGO); static bool __read_mostly nested_early_check = 0; module_param(nested_early_check, bool, S_IRUGO); -#define CC(consistency_check) \ -({ \ - bool failed = (consistency_check); \ - if (failed) \ - trace_kvm_nested_vmenter_failed(#consistency_check, 0); \ - failed; \ -}) +#define CC KVM_NESTED_VMENTER_CONSISTENCY_CHECK /* * Hyper-V requires all of these, so mark them as supported even though diff --git a/arch/x86/kvm/x86.h b/arch/x86/kvm/x86.h index 39eb04887141..ee6e01067884 100644 --- a/arch/x86/kvm/x86.h +++ b/arch/x86/kvm/x86.h @@ -8,6 +8,14 @@ #include "kvm_cache_regs.h" #include "kvm_emulate.h" +#define KVM_NESTED_VMENTER_CONSISTENCY_CHECK(consistency_check) \ +({ \ + bool failed = (consistency_check); \ + if (failed) \ + trace_kvm_nested_vmenter_failed(#consistency_check, 0); \ + failed; \ +}) + #define KVM_DEFAULT_PLE_GAP128 #define KVM_VMX_DEFAULT_PLE_WINDOW 4096 #define KVM_DEFAULT_PLE_WINDOW_GROW2 -- 2.26.2
[PATCH 18/23] KVM: SVM: Don't manually emulate RDPMC if nrips=0
From: Sean Christopherson Remove bizarre code that causes KVM to run RDPMC through the emulator when nrips is disabled. Accelerated emulation of RDPMC doesn't rely on any additional data from the VMCB, and SVM has generic handling for updating RIP to skip instructions when nrips is disabled. Signed-off-by: Sean Christopherson Message-Id: <20210205005750.3841462-9-sea...@google.com> Signed-off-by: Paolo Bonzini --- arch/x86/kvm/svm/svm.c | 10 +- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index 8cb31603bce5..3725a4636930 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -2424,14 +2424,6 @@ static int rsm_interception(struct kvm_vcpu *vcpu) return kvm_emulate_instruction_from_buffer(vcpu, rsm_ins_bytes, 2); } -static int rdpmc_interception(struct kvm_vcpu *vcpu) -{ - if (!nrips) - return emulate_on_interception(vcpu); - - return kvm_emulate_rdpmc(vcpu); -} - static bool check_selective_cr0_intercepted(struct kvm_vcpu *vcpu, unsigned long val) { @@ -3058,7 +3050,7 @@ static int (*const svm_exit_handlers[])(struct kvm_vcpu *vcpu) = { [SVM_EXIT_SMI] = kvm_emulate_as_nop, [SVM_EXIT_INIT] = kvm_emulate_as_nop, [SVM_EXIT_VINTR]= interrupt_window_interception, - [SVM_EXIT_RDPMC]= rdpmc_interception, + [SVM_EXIT_RDPMC]= kvm_emulate_rdpmc, [SVM_EXIT_CPUID]= kvm_emulate_cpuid, [SVM_EXIT_IRET] = iret_interception, [SVM_EXIT_INVD] = kvm_emulate_invd, -- 2.26.2
[PATCH 20/23] KVM: SVM: move VMLOAD/VMSAVE to C code
Thanks to the new macros that handle exception handling for SVM instructions, it is easier to just do the VMLOAD/VMSAVE in C. This is safe, as shown by the fact that the host reload is already done outside the assembly source. Signed-off-by: Paolo Bonzini --- arch/x86/kvm/svm/svm.c | 2 ++ arch/x86/kvm/svm/vmenter.S | 14 +- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index 1c62d3ec7e53..a0df44f6c239 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -3719,7 +3719,9 @@ static noinstr void svm_vcpu_enter_exit(struct kvm_vcpu *vcpu) } else { struct svm_cpu_data *sd = per_cpu(svm_data, vcpu->cpu); + vmload(svm->vmcb_pa); __svm_vcpu_run(svm->vmcb_pa, (unsigned long *)&vcpu->arch.regs); + vmsave(svm->vmcb_pa); vmload(__sme_page_pa(sd->save_area)); } diff --git a/arch/x86/kvm/svm/vmenter.S b/arch/x86/kvm/svm/vmenter.S index 6feb8c08f45a..343108bf0f8c 100644 --- a/arch/x86/kvm/svm/vmenter.S +++ b/arch/x86/kvm/svm/vmenter.S @@ -79,12 +79,6 @@ SYM_FUNC_START(__svm_vcpu_run) /* Enter guest mode */ sti -1: vmload %_ASM_AX - jmp 3f -2: cmpb $0, kvm_rebooting - jne 3f - ud2 - _ASM_EXTABLE(1b, 2b) 3: vmrun %_ASM_AX jmp 5f @@ -93,13 +87,7 @@ SYM_FUNC_START(__svm_vcpu_run) ud2 _ASM_EXTABLE(3b, 4b) -5: vmsave %_ASM_AX - jmp 7f -6: cmpb $0, kvm_rebooting - jne 7f - ud2 - _ASM_EXTABLE(5b, 6b) -7: +5: cli #ifdef CONFIG_RETPOLINE -- 2.26.2
[PATCH 08/23] KVM: nSVM: only copy L1 non-VMLOAD/VMSAVE data in svm_set_nested_state()
The VMLOAD/VMSAVE data is not taken from userspace, since it will not be restored on VMEXIT (it will be copied from VMCB02 to VMCB01). For clarity, replace the wholesale copy of the VMCB save area with a copy of that state only. Signed-off-by: Paolo Bonzini --- arch/x86/kvm/svm/nested.c | 20 ++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/arch/x86/kvm/svm/nested.c b/arch/x86/kvm/svm/nested.c index 945c2a48b591..585b5aa1914f 100644 --- a/arch/x86/kvm/svm/nested.c +++ b/arch/x86/kvm/svm/nested.c @@ -715,7 +715,7 @@ int nested_svm_vmexit(struct vcpu_svm *svm) /* * Restore processor state that had been saved in vmcb01 */ - kvm_set_rflags(&svm->vcpu, svm->vmcb->save.rflags | X86_EFLAGS_FIXED); + kvm_set_rflags(&svm->vcpu, svm->vmcb->save.rflags); svm_set_efer(&svm->vcpu, svm->vmcb->save.efer); svm_set_cr0(&svm->vcpu, svm->vmcb->save.cr0 | X86_CR0_PE); svm_set_cr4(&svm->vcpu, svm->vmcb->save.cr4); @@ -1250,7 +1250,23 @@ static int svm_set_nested_state(struct kvm_vcpu *vcpu, svm->nested.vmcb12_gpa = kvm_state->hdr.svm.vmcb_pa; if (svm->current_vmcb == &svm->vmcb01) svm->nested.vmcb02.ptr->save = svm->vmcb01.ptr->save; - svm->vmcb01.ptr->save = *save; + + svm->vmcb01.ptr->save.es = save->es; + svm->vmcb01.ptr->save.cs = save->cs; + svm->vmcb01.ptr->save.ss = save->ss; + svm->vmcb01.ptr->save.ds = save->ds; + svm->vmcb01.ptr->save.gdtr = save->gdtr; + svm->vmcb01.ptr->save.idtr = save->idtr; + svm->vmcb01.ptr->save.rflags = save->rflags | X86_EFLAGS_FIXED; + svm->vmcb01.ptr->save.efer = save->efer; + svm->vmcb01.ptr->save.cr0 = save->cr0; + svm->vmcb01.ptr->save.cr3 = save->cr3; + svm->vmcb01.ptr->save.cr4 = save->cr4; + svm->vmcb01.ptr->save.rax = save->rax; + svm->vmcb01.ptr->save.rsp = save->rsp; + svm->vmcb01.ptr->save.rip = save->rip; + svm->vmcb01.ptr->save.cpl = 0; + nested_load_control_from_vmcb12(svm, ctl); svm_switch_vmcb(svm, &svm->nested.vmcb02); -- 2.26.2
[PATCH 19/23] KVM: SVM: Skip intercepted PAUSE instructions after emulation
From: Sean Christopherson Skip PAUSE after interception to avoid unnecessarily re-executing the instruction in the guest, e.g. after regaining control post-yield. This is a benign bug as KVM disables PAUSE interception if filtering is off, including the case where pause_filter_count is set to zero. Signed-off-by: Sean Christopherson Message-Id: <20210205005750.3841462-10-sea...@google.com> Signed-off-by: Paolo Bonzini --- arch/x86/kvm/svm/svm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index 3725a4636930..1c62d3ec7e53 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -2982,7 +2982,7 @@ static int pause_interception(struct kvm_vcpu *vcpu) grow_ple_window(vcpu); kvm_vcpu_on_spin(vcpu, in_kernel); - return 1; + return kvm_skip_emulated_instruction(vcpu); } static int invpcid_interception(struct kvm_vcpu *vcpu) -- 2.26.2
[PATCH 05/23] KVM: nSVM: do not copy vmcb01->control blindly to vmcb02->control
Most fields were going to be overwritten by vmcb12 control fields, or do not matter at all because they are filled by the processor on vmexit. Therefore, we need not copy them from vmcb01 to vmcb02 on vmentry. Signed-off-by: Paolo Bonzini --- arch/x86/kvm/svm/nested.c | 23 +-- arch/x86/kvm/svm/svm.h| 2 +- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/arch/x86/kvm/svm/nested.c b/arch/x86/kvm/svm/nested.c index 4d136465dee1..f88d0614d9b8 100644 --- a/arch/x86/kvm/svm/nested.c +++ b/arch/x86/kvm/svm/nested.c @@ -428,9 +428,28 @@ static void nested_vmcb02_prepare_control(struct vcpu_svm *svm) { const u32 mask = V_INTR_MASKING_MASK | V_GIF_ENABLE_MASK | V_GIF_MASK; - /* FIXME: go through each field one by one. */ - svm->nested.vmcb02.ptr->control = svm->vmcb01.ptr->control; + /* +* Filled at exit: exit_code, exit_code_hi, exit_info_1, exit_info_2, +* exit_int_info, exit_int_info_err, next_rip, insn_len, insn_bytes. +*/ + + /* +* Also covers avic_vapic_bar, avic_backing_page, avic_logical_id, +* avic_physical_id. +*/ + WARN_ON(svm->vmcb01.ptr->control.int_ctl & AVIC_ENABLE_MASK); + + /* Copied from vmcb01. msrpm_base can be overwritten later. */ + svm->vmcb->control.nested_ctl = svm->vmcb01.ptr->control.nested_ctl; + svm->vmcb->control.iopm_base_pa = svm->vmcb01.ptr->control.iopm_base_pa; + svm->vmcb->control.msrpm_base_pa = svm->vmcb01.ptr->control.msrpm_base_pa; + + /* Done at vmrun: asid. */ + + /* Also overwritten later if necessary. */ + svm->vmcb->control.tlb_ctl = TLB_CONTROL_DO_NOTHING; + /* nested_cr3. */ if (nested_npt_enabled(svm)) nested_svm_init_mmu_context(&svm->vcpu); -- 2.26.2
Re: [PATCH 0/2] KVM: x86: Emulate L2 triple fault without killing L1
On 02/03/21 18:45, Sean Christopherson wrote: If KVM (L0) intercepts #GP, but L1 does not, then L2 can kill L1 by triggering triple fault. On both VMX and SVM, if the CPU hits a fault while vectoring an injected #DF (or I supposed any #DF), any intercept from the hypervisor takes priority over triple fault. #PF is unlikely to be intercepted by L0 but not L1. The bigger problem is #GP, which is intercepted on both VMX and SVM if enable_vmware_backdoor=1, and is also now intercepted for the lovely VMRUN/VMLOAD/VMSAVE errata. Based on kvm/queue, commit fe5f0041c026 ("KVM/SVM: Move vmenter.S exception fixups out of line"). x86.c and svm/nested.c conflict with kvm/master. They are minor and straighforward, but let me know if you want me to post a version based on kvm/master for easier inclusion into 5.12. Sean Christopherson (2): KVM: x86: Handle triple fault in L2 without killing L1 KVM: nSVM: Add helper to synthesize nested VM-Exit without collateral arch/x86/include/asm/kvm_host.h | 1 + arch/x86/kvm/lapic.c| 2 +- arch/x86/kvm/svm/nested.c | 57 - arch/x86/kvm/svm/svm.c | 6 +--- arch/x86/kvm/svm/svm.h | 9 ++ arch/x86/kvm/vmx/nested.c | 9 ++ arch/x86/kvm/x86.c | 29 + arch/x86/kvm/x86.h | 2 ++ 8 files changed, 60 insertions(+), 55 deletions(-) Queued, thanks. Paolo
[PATCH 11/23] KVM: nSVM: Trace VM-Enter consistency check failures
From: Sean Christopherson Use trace_kvm_nested_vmenter_failed() and its macro magic to trace consistency check failures on nested VMRUN. Tracing such failures by running the buggy VMM as a KVM guest is often the only way to get a precise explanation of why VMRUN failed. Signed-off-by: Sean Christopherson Message-Id: <20210204000117.3303214-13-sea...@google.com> Signed-off-by: Paolo Bonzini --- arch/x86/kvm/svm/nested.c | 33 +++-- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/arch/x86/kvm/svm/nested.c b/arch/x86/kvm/svm/nested.c index cadf776f58f7..03a06f959bc8 100644 --- a/arch/x86/kvm/svm/nested.c +++ b/arch/x86/kvm/svm/nested.c @@ -29,6 +29,8 @@ #include "lapic.h" #include "svm.h" +#define CC KVM_NESTED_VMENTER_CONSISTENCY_CHECK + static void nested_svm_inject_npf_exit(struct kvm_vcpu *vcpu, struct x86_exception *fault) { @@ -233,14 +235,13 @@ static bool svm_get_nested_state_pages(struct kvm_vcpu *vcpu) static bool nested_vmcb_check_controls(struct vmcb_control_area *control) { - if ((vmcb_is_intercept(control, INTERCEPT_VMRUN)) == 0) + if (CC(!vmcb_is_intercept(control, INTERCEPT_VMRUN))) return false; - if (control->asid == 0) + if (CC(control->asid == 0)) return false; - if ((control->nested_ctl & SVM_NESTED_CTL_NP_ENABLE) && - !npt_enabled) + if (CC((control->nested_ctl & SVM_NESTED_CTL_NP_ENABLE) && !npt_enabled)) return false; return true; @@ -257,32 +258,36 @@ static bool nested_vmcb_check_cr3_cr4(struct vcpu_svm *svm, * CR0.PG && EFER.LME. */ if ((save->efer & EFER_LME) && (save->cr0 & X86_CR0_PG)) { - if (!(save->cr4 & X86_CR4_PAE) || !(save->cr0 & X86_CR0_PE) || - kvm_vcpu_is_illegal_gpa(vcpu, save->cr3)) + if (CC(!(save->cr4 & X86_CR4_PAE)) || + CC(!(save->cr0 & X86_CR0_PE)) || + CC(kvm_vcpu_is_illegal_gpa(vcpu, save->cr3))) return false; } - return kvm_is_valid_cr4(&svm->vcpu, save->cr4); + if (CC(!kvm_is_valid_cr4(vcpu, save->cr4))) + return false; + + return true; } /* Common checks that apply to both L1 and L2 state. */ static bool nested_vmcb_valid_sregs(struct vcpu_svm *svm, struct vmcb_save_area *save) { - if (!(save->efer & EFER_SVME)) + if (CC(!(save->efer & EFER_SVME))) return false; - if (((save->cr0 & X86_CR0_CD) == 0 && (save->cr0 & X86_CR0_NW)) || - (save->cr0 & ~0xULL)) + if (CC((save->cr0 & X86_CR0_CD) == 0 && (save->cr0 & X86_CR0_NW)) || + CC(save->cr0 & ~0xULL)) return false; - if (!kvm_dr6_valid(save->dr6) || !kvm_dr7_valid(save->dr7)) + if (CC(!kvm_dr6_valid(save->dr6)) || CC(!kvm_dr7_valid(save->dr7))) return false; if (!nested_vmcb_check_cr3_cr4(svm, save)) return false; - if (!kvm_valid_efer(&svm->vcpu, save->efer)) + if (CC(!kvm_valid_efer(&svm->vcpu, save->efer))) return false; return true; @@ -384,12 +389,12 @@ static inline bool nested_npt_enabled(struct vcpu_svm *svm) static int nested_svm_load_cr3(struct kvm_vcpu *vcpu, unsigned long cr3, bool nested_npt) { - if (kvm_vcpu_is_illegal_gpa(vcpu, cr3)) + if (CC(kvm_vcpu_is_illegal_gpa(vcpu, cr3))) return -EINVAL; if (!nested_npt && is_pae_paging(vcpu) && (cr3 != kvm_read_cr3(vcpu) || pdptrs_changed(vcpu))) { - if (!load_pdptrs(vcpu, vcpu->arch.walk_mmu, cr3)) + if (CC(!load_pdptrs(vcpu, vcpu->arch.walk_mmu, cr3))) return -EINVAL; } -- 2.26.2
[PATCH 22/23] x86/cpufeatures: Add the Virtual SPEC_CTRL feature
From: Babu Moger Newer AMD processors have a feature to virtualize the use of the SPEC_CTRL MSR. Presence of this feature is indicated via CPUID function 0x800A_EDX[20]: GuestSpecCtrl. When present, the SPEC_CTRL MSR is automatically virtualized. Signed-off-by: Babu Moger Acked-by: Borislav Petkov Message-Id: <161188100272.28787.4097272856384825024.stgit@bmoger-ubuntu> Signed-off-by: Paolo Bonzini --- arch/x86/include/asm/cpufeatures.h | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h index f1957b3c8e4e..9ac7ad4d8239 100644 --- a/arch/x86/include/asm/cpufeatures.h +++ b/arch/x86/include/asm/cpufeatures.h @@ -338,6 +338,7 @@ #define X86_FEATURE_AVIC (15*32+13) /* Virtual Interrupt Controller */ #define X86_FEATURE_V_VMSAVE_VMLOAD(15*32+15) /* Virtual VMSAVE VMLOAD */ #define X86_FEATURE_VGIF (15*32+16) /* Virtual GIF */ +#define X86_FEATURE_V_SPEC_CTRL(15*32+20) /* Virtual SPEC_CTRL */ #define X86_FEATURE_SVME_ADDR_CHK (15*32+28) /* "" SVME addr check */ /* Intel-defined CPU features, CPUID level 0x0007:0 (ECX), word 16 */ -- 2.26.2
Re: [PATCH] gpio: regmap: move struct gpio_regmap definition
Hi Michael, El 02/03/2021 a las 20:24, Michael Walle escribió: Hi, Am 2021-03-02 19:14, schrieb Álvaro Fernández Rojas: El 02/03/2021 a las 19:10, Michael Walle escribió: Am 2021-03-02 19:06, schrieb Álvaro Fernández Rojas: struct gpio_regmap should be declared in gpio/regmap.h. This way other drivers can access the structure data when registering a gpio regmap controller. The intention was really to keep this private to the gpio-regmap driver. Why do you need to access to the properties? I'm trying to add support for bcm63xx pin controllers, and Linus suggested that I could use gpio regmap instead of adding duplicated code. nice! However, I need to access gpio_chip inside gpio_regmap to call pinctrl_add_gpio_range() with gpio_chip.base. Can't we add something to gpio-regmap.c which will (1) either call pinctrl_add_gpio_range(), just (2) return the struct gpio_chip* or (3) even only gpio_chip.base? Sure, I'm OK with any way of doing it, so it's up to you and Linus :) I don't know how many sense (1) make and how reusable that code would be for other drivers, though. Linus? -michael Best regards, Álvaro.
Re: [PATCH 6/7] x86/boot/compressed/64: Check SEV encryption in 32-bit boot-path
On Wed, Feb 10, 2021 at 11:21:34AM +0100, Joerg Roedel wrote: > + /* > + * Store the sme_me_mask as an indicator that SEV is active. It will be > + * set again in startup_64(). So why bother? Or does something needs it before that? ... > +SYM_FUNC_START(sev_startup32_cbit_check) s/sev_startup32_cbit_check/startup32_check_sev_cbit/ I guess. -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette
[PATCH 04/23] KVM: nSVM: rename functions and variables according to vmcbXY nomenclature
Now that SVM is using a separate vmcb01 and vmcb02 (and also uses the vmcb12 naming) we can give clearer names to functions that write to and read from those VMCBs. Likewise, variables and parameters can be renamed from nested_vmcb to vmcb12. Signed-off-by: Paolo Bonzini --- arch/x86/kvm/svm/nested.c | 28 ++-- arch/x86/kvm/svm/svm.c| 14 +++--- arch/x86/kvm/svm/svm.h| 5 ++--- 3 files changed, 23 insertions(+), 24 deletions(-) diff --git a/arch/x86/kvm/svm/nested.c b/arch/x86/kvm/svm/nested.c index 3bbb4acdf956..4d136465dee1 100644 --- a/arch/x86/kvm/svm/nested.c +++ b/arch/x86/kvm/svm/nested.c @@ -274,8 +274,8 @@ static bool nested_vmcb_checks(struct vcpu_svm *svm, struct vmcb *vmcb12) return nested_vmcb_check_controls(&vmcb12->control); } -static void load_nested_vmcb_control(struct vcpu_svm *svm, -struct vmcb_control_area *control) +static void nested_load_control_from_vmcb12(struct vcpu_svm *svm, + struct vmcb_control_area *control) { copy_vmcb_control_area(&svm->nested.ctl, control); @@ -287,9 +287,9 @@ static void load_nested_vmcb_control(struct vcpu_svm *svm, /* * Synchronize fields that are written by the processor, so that - * they can be copied back into the nested_vmcb. + * they can be copied back into the vmcb12. */ -void sync_nested_vmcb_control(struct vcpu_svm *svm) +void nested_sync_control_from_vmcb02(struct vcpu_svm *svm) { u32 mask; svm->nested.ctl.event_inj = svm->vmcb->control.event_inj; @@ -317,8 +317,8 @@ void sync_nested_vmcb_control(struct vcpu_svm *svm) * Transfer any event that L0 or L1 wanted to inject into L2 to * EXIT_INT_INFO. */ -static void nested_vmcb_save_pending_event(struct vcpu_svm *svm, - struct vmcb *vmcb12) +static void nested_save_pending_event_to_vmcb12(struct vcpu_svm *svm, + struct vmcb *vmcb12) { struct kvm_vcpu *vcpu = &svm->vcpu; u32 exit_int_info = 0; @@ -395,7 +395,7 @@ void nested_vmcb02_compute_g_pat(struct vcpu_svm *svm) svm->nested.vmcb02.ptr->save.g_pat = svm->vmcb01.ptr->save.g_pat; } -static void nested_prepare_vmcb_save(struct vcpu_svm *svm, struct vmcb *vmcb12) +static void nested_vmcb02_prepare_save(struct vcpu_svm *svm, struct vmcb *vmcb12) { nested_vmcb02_compute_g_pat(svm); @@ -424,7 +424,7 @@ static void nested_prepare_vmcb_save(struct vcpu_svm *svm, struct vmcb *vmcb12) svm->vmcb->save.cpl = vmcb12->save.cpl; } -static void nested_prepare_vmcb_control(struct vcpu_svm *svm) +static void nested_vmcb02_prepare_control(struct vcpu_svm *svm) { const u32 mask = V_INTR_MASKING_MASK | V_GIF_ENABLE_MASK | V_GIF_MASK; @@ -486,11 +486,11 @@ int enter_svm_guest_mode(struct vcpu_svm *svm, u64 vmcb12_gpa, WARN_ON(svm->vmcb == svm->nested.vmcb02.ptr); nested_svm_vmloadsave(svm->vmcb01.ptr, svm->nested.vmcb02.ptr); - load_nested_vmcb_control(svm, &vmcb12->control); + nested_load_control_from_vmcb12(svm, &vmcb12->control); svm_switch_vmcb(svm, &svm->nested.vmcb02); - nested_prepare_vmcb_control(svm); - nested_prepare_vmcb_save(svm, vmcb12); + nested_vmcb02_prepare_control(svm); + nested_vmcb02_prepare_save(svm, vmcb12); ret = nested_svm_load_cr3(&svm->vcpu, vmcb12->save.cr3, nested_npt_enabled(svm)); @@ -653,7 +653,7 @@ int nested_svm_vmexit(struct vcpu_svm *svm) vmcb12->control.exit_info_2 = vmcb->control.exit_info_2; if (vmcb12->control.exit_code != SVM_EXIT_ERR) - nested_vmcb_save_pending_event(svm, vmcb12); + nested_save_pending_event_to_vmcb12(svm, vmcb12); if (svm->nrips_enabled) vmcb12->control.next_rip = vmcb->control.next_rip; @@ -1225,11 +1225,11 @@ static int svm_set_nested_state(struct kvm_vcpu *vcpu, if (svm->current_vmcb == &svm->vmcb01) svm->nested.vmcb02.ptr->save = svm->vmcb01.ptr->save; svm->vmcb01.ptr->save = *save; - load_nested_vmcb_control(svm, ctl); + nested_load_control_from_vmcb12(svm, ctl); svm_switch_vmcb(svm, &svm->nested.vmcb02); - nested_prepare_vmcb_control(svm); + nested_vmcb02_prepare_control(svm); kvm_make_request(KVM_REQ_GET_NESTED_STATE_PAGES, vcpu); ret = 0; diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index aa1baf646ff0..e7fcd92551e5 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -2122,7 +2122,7 @@ static int vmmcall_interception(struct vcpu_svm *svm) static int vmload_interception(struct vcpu_svm *svm) { - struct vmcb *nested_vmcb; + struct vmcb *vmcb12; struct kvm_host_map map; int ret; @@ -2136,11 +2136,11 @@ static int vmload_interception(struct vcpu_svm
[ANNOUNCE] v5.11.2-rt9
Dear RT folks! I'm pleased to announce the v5.11.2-rt9 patch set. Changes since v5.11.2-rt8: - Move the cpu_chill() prototype to hrtimer.h to avoid a warning. - Polish the sigqueue cache patch. Its doing remains unchanged with one difference: The cache is now used only if the task is a realtime task. Previously it was also used if a task was having a realtime priority due to PI boost. - Refurbish the slub and page_alloc patches: - There used to be a per-CPU list for pages which should have been given back to the page-alloctor but the caller was atomic. The atomic sections from within SLUB are gone, the per-CPU list is gone, too. - The SLUB_CPU_PARTIAL switch can now be enabled. I looked at the resulting latency numbers and enabling leads to higher latency. Therefore it is off by default on RT. - We used to split the free process of the pcp-pages into two stages and so slightly decouple the IRQ-off section from the zone-lock section. I don't see the need to keep doing it since the local-lock removes all the IRQ-off regions on RT and for !RT it shouldn't make much difference. This split is gone now. - The alloc/free tracker sysfs file uses one PAGE size for collecting the results. If it runs out of space it reallocates more memory with disabled interrupts. The reallocation is not forbidden on PREEMPT_RT. Known issues - kdb/kgdb can easily deadlock. - netconsole triggers WARN. The delta patch against v5.11.2-rt8 is appended below and can be found here: https://cdn.kernel.org/pub/linux/kernel/projects/rt/5.11/incr/patch-5.11.2-rt8-rt9.patch.xz You can get this release via the git tree at: git://git.kernel.org/pub/scm/linux/kernel/git/rt/linux-rt-devel.git v5.11.2-rt9 The RT patch against v5.11.2 can be found here: https://cdn.kernel.org/pub/linux/kernel/projects/rt/5.11/older/patch-5.11.2-rt9.patch.xz The split quilt queue is available at: https://cdn.kernel.org/pub/linux/kernel/projects/rt/5.11/older/patches-5.11.2-rt9.tar.xz Sebastian diff --git a/fs/namespace.c b/fs/namespace.c index 45571517b9c21..d02bd66933735 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -14,7 +14,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/include/linux/delay.h b/include/linux/delay.h index 02b37178b54f4..1d0e2ce6b6d9f 100644 --- a/include/linux/delay.h +++ b/include/linux/delay.h @@ -76,10 +76,4 @@ static inline void fsleep(unsigned long usecs) msleep(DIV_ROUND_UP(usecs, 1000)); } -#ifdef CONFIG_PREEMPT_RT -extern void cpu_chill(void); -#else -# define cpu_chill() cpu_relax() -#endif - #endif /* defined(_LINUX_DELAY_H) */ diff --git a/include/linux/hrtimer.h b/include/linux/hrtimer.h index bb5e7b0a42746..e425a26a5ed88 100644 --- a/include/linux/hrtimer.h +++ b/include/linux/hrtimer.h @@ -540,4 +540,10 @@ int hrtimers_dead_cpu(unsigned int cpu); #define hrtimers_dead_cpu NULL #endif +#ifdef CONFIG_PREEMPT_RT +extern void cpu_chill(void); +#else +# define cpu_chill() cpu_relax() +#endif + #endif diff --git a/init/Kconfig b/init/Kconfig index fa25113eda0dc..77d356fa8668e 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -1972,8 +1972,8 @@ config SHUFFLE_PAGE_ALLOCATOR Say Y if unsure. config SLUB_CPU_PARTIAL - default y - depends on SLUB && SMP && !PREEMPT_RT + default y if !PREEMPT_RT + depends on SLUB && SMP bool "SLUB per cpu partial cache" help Per cpu partial caches accelerate objects allocation and freeing diff --git a/kernel/signal.c b/kernel/signal.c index b87178eb0df69..e40ed99a62a17 100644 --- a/kernel/signal.c +++ b/kernel/signal.c @@ -405,20 +405,20 @@ void task_join_group_stop(struct task_struct *task) task_set_jobctl_pending(task, mask | JOBCTL_STOP_PENDING); } -static inline struct sigqueue *get_task_cache(struct task_struct *t) +static struct sigqueue *sigqueue_from_cache(struct task_struct *t) { struct sigqueue *q = t->sigqueue_cache; - if (cmpxchg(&t->sigqueue_cache, q, NULL) != q) - return NULL; - return q; + if (q && cmpxchg(&t->sigqueue_cache, q, NULL) == q) + return q; + return NULL; } -static inline int put_task_cache(struct task_struct *t, struct sigqueue *q) +static bool sigqueue_add_cache(struct task_struct *t, struct sigqueue *q) { - if (cmpxchg(&t->sigqueue_cache, NULL, q) == NULL) - return 0; - return 1; + if (!t->sigqueue_cache && cmpxchg(&t->sigqueue_cache, NULL, q) == NULL) + return true; + return false; } /* @@ -428,7 +428,7 @@ static inline int put_task_cache(struct task_struct *t, struct sigqueue *q) */ static struct sigqueue * __sigqueue_do_alloc(int sig, struct task_struct *t, gfp_t flags, - int override_rlimit, int fromslab) +
Re: [PATCH] KVM: SVM: Clear the CR4 register on reset
On 02/03/21 19:51, Babu Moger wrote: This problem was reported on a SVM guest while executing kexec. Kexec fails to load the new kernel when the PCID feature is enabled. When kexec starts loading the new kernel, it starts the process by resetting the vCPU's and then bringing each vCPU online one by one. The vCPU reset is supposed to reset all the register states before the vCPUs are brought online. However, the CR4 register is not reset during this process. If this register is already setup during the last boot, all the flags can remain intact. The X86_CR4_PCIDE bit can only be enabled in long mode. So, it must be enabled much later in SMP initialization. Having the X86_CR4_PCIDE bit set during SMP boot can cause a boot failures. Fix the issue by resetting the CR4 register in init_vmcb(). Signed-off-by: Babu Moger --- arch/x86/kvm/svm/svm.c |1 + 1 file changed, 1 insertion(+) diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index c636021b066b..baee91c1e936 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -1200,6 +1200,7 @@ static void init_vmcb(struct vcpu_svm *svm) init_sys_seg(&save->ldtr, SEG_TYPE_LDT); init_sys_seg(&save->tr, SEG_TYPE_BUSY_TSS16); + svm_set_cr4(&svm->vcpu, 0); svm_set_efer(&svm->vcpu, 0); save->dr6 = 0x0ff0; kvm_set_rflags(&svm->vcpu, X86_EFLAGS_FIXED); Queued, thanks. Paolo
[PATCH 02/23] KVM: nSVM: Track the physical cpu of the vmcb vmrun through the vmcb
From: Cathy Avery This patch moves the physical cpu tracking from the vcpu to the vmcb in svm_switch_vmcb. If either vmcb01 or vmcb02 change physical cpus from one vmrun to the next the vmcb's previous cpu is preserved for comparison with the current cpu and the vmcb is marked dirty if different. This prevents the processor from using old cached data for a vmcb that may have been updated on a prior run on a different processor. It also moves the physical cpu check from svm_vcpu_load to pre_svm_run as the check only needs to be done at run. Suggested-by: Paolo Bonzini Signed-off-by: Cathy Avery Message-Id: <20210112164313.4204-2-cav...@redhat.com> Signed-off-by: Paolo Bonzini --- arch/x86/kvm/svm/svm.c | 23 +++ arch/x86/kvm/svm/svm.h | 1 + 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index 1d24129496d0..c35285c926e0 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -1317,11 +1317,12 @@ void svm_switch_vmcb(struct vcpu_svm *svm, struct kvm_vmcb_info *target_vmcb) svm->asid_generation = 0; /* - * Workaround: we don't yet track the physical CPU that - * target_vmcb has run on. + * Track the physical CPU the target_vmcb is running on + * in order to mark the VMCB dirty if the cpu changes at + * its next vmrun. */ - vmcb_mark_all_dirty(svm->vmcb); + svm->current_vmcb->cpu = svm->vcpu.cpu; } static int svm_create_vcpu(struct kvm_vcpu *vcpu) @@ -1497,11 +1498,6 @@ static void svm_vcpu_load(struct kvm_vcpu *vcpu, int cpu) struct vcpu_svm *svm = to_svm(vcpu); struct svm_cpu_data *sd = per_cpu(svm_data, cpu); - if (unlikely(cpu != vcpu->cpu)) { - svm->asid_generation = 0; - vmcb_mark_all_dirty(svm->vmcb); - } - if (sd->current_vmcb != svm->vmcb) { sd->current_vmcb = svm->vmcb; indirect_branch_prediction_barrier(); @@ -3433,6 +3429,17 @@ static void pre_svm_run(struct vcpu_svm *svm) { struct svm_cpu_data *sd = per_cpu(svm_data, svm->vcpu.cpu); + /* +* If the previous vmrun of the vmcb occurred on +* a different physical cpu then we must mark the vmcb dirty. +*/ + +if (unlikely(svm->current_vmcb->cpu != svm->vcpu.cpu)) { + svm->asid_generation = 0; + vmcb_mark_all_dirty(svm->vmcb); + svm->current_vmcb->cpu = svm->vcpu.cpu; +} + if (sev_guest(svm->vcpu.kvm)) return pre_sev_run(svm, svm->vcpu.cpu); diff --git a/arch/x86/kvm/svm/svm.h b/arch/x86/kvm/svm/svm.h index 818b37388d8c..a37281097751 100644 --- a/arch/x86/kvm/svm/svm.h +++ b/arch/x86/kvm/svm/svm.h @@ -84,6 +84,7 @@ struct kvm_vcpu; struct kvm_vmcb_info { struct vmcb *ptr; unsigned long pa; + int cpu; }; struct svm_nested_state { -- 2.26.2
Re: [PATCH] ALSA: hda/realtek: Add quirk for Clevo NH55RZQ
Hello Takashi, > The patch isn't cleanly applicable. Could you try to submit via > git-send-email instead? I'm sorry the editor + mailer i used replaced tabs with spaces and made a html mail. Already resend the patch with tabs, but only after that I realized that even the "plain" mails are converted to html. It's probably still broken so don't waste your time with it, i will read the man page of git send-mail now ^^. > Cc to stable is worthwhile. You can simply add > Cc: > > around your signed-off-by lines in the patch. Ok (also forgot that in my resend patch) Kind regards, Werner Sembach
Re: XDP socket rings, and LKMM litmus tests
On Tue, Mar 02, 2021 at 07:46:27PM +0100, Björn Töpel wrote: > Hi! > > Firstly; The long Cc-list is to reach the LKMM-folks. > > Some background; the XDP sockets use a ring-buffer to communicate > between the kernel and userland. It's a > single-consumer/single-producer ring, and described in > net/xdp/xsk_queue.h. > > --8<--- > /* The structure of the shared state of the rings are the same as the > * ring buffer in kernel/events/ring_buffer.c. For the Rx and completion > * ring, the kernel is the producer and user space is the consumer. For > * the Tx and fill rings, the kernel is the consumer and user space is > * the producer. > * > * producer consumer > * > * if (LOAD ->consumer) { LOAD ->producer > *(A) smp_rmb() (C) > *STORE $data LOAD $data > *smp_wmb() (B) smp_mb()(D) > *STORE ->producer STORE ->consumer > * } > * > * (A) pairs with (D), and (B) pairs with (C). > ... > -->8--- > > I'd like to replace the smp_{r,w,}mb() barriers with acquire-release > semantics [1], without breaking existing userspace applications. > > So, I figured I'd use herd7 and the LKMM model to build a litmus test > for the barrier version, then for the acquire-release version, and > finally permutations of both. > > The idea is to use a one element ring, with a state machine outlined > in the litmus test. > > The basic test for the existing smp_{r,w,}mb() barriers looks like: > > $ cat spsc-rb+1p1c.litmus > C spsc-rb+1p1c > > // Stupid one entry ring: > // prod cons allowed action prod cons > //00 => prod => 10 > //01 => cons => 00 > //10 => cons => 11 > //11 => prod => 01 > > { prod = 1; } > > // Here, we start at prod==1,cons==0, data==0, i.e. producer has > // written data=0, so from here only the consumer can start, and should > // consume data==0. Afterwards, producer can continue and write 1 to > // data. Can we enter state prod==0, cons==1, but consumer observerd > // the write of 1? > > P0(int *prod, int *cons, int *data) > { > int p; > int c; > int cond = 0; > > p = READ_ONCE(*prod); > c = READ_ONCE(*cons); > if (p == 0) > if (c == 0) > cond = 1; > if (p == 1) > if (c == 1) > cond = 1; > > if (cond) { > smp_mb(); > WRITE_ONCE(*data, 1); > smp_wmb(); > WRITE_ONCE(*prod, p ^ 1); > } > } > > P1(int *prod, int *cons, int *data) > { > int p; > int c; > int d = -1; > int cond = 0; > > p = READ_ONCE(*prod); > c = READ_ONCE(*cons); > if (p == 1) > if (c == 0) > cond = 1; > if (p == 0) > if (c == 1) > cond = 1; > > if (cond == 1) { > smp_rmb(); > d = READ_ONCE(*data); > smp_mb(); > WRITE_ONCE(*cons, c ^ 1); > } > } Before digging in too deeply, does the following simplification still capture your intent? P0(int *prod, int *cons, int *data) { int p; int cond = 0; p = READ_ONCE(*prod); if (p == READ_ONCE(*cons)) cond = 1; if (cond) { smp_mb(); WRITE_ONCE(*data, 1); smp_wmb(); WRITE_ONCE(*prod, p ^ 1); } } P1(int *prod, int *cons, int *data) { int c; int d = -1; int cond = 0; c = READ_ONCE(*cons); if (READ_ONCE(*prod) == c) cond = 1; if (cond == 1) { smp_rmb(); d = READ_ONCE(*data); smp_mb(); WRITE_ONCE(*cons, c ^ 1); } } Thanx, Paul > exists( 1:d=1 /\ prod=0 /\ cons=1 ); > > -- > > The weird state changing if-statements is because that I didn't get > '&&' and '||' to work with herd. > > When this is run: > > $ herd7 -conf linux-kernel.cfg litmus-tests/spsc-rb+1p1c.litmus > Test spsc-rb+1p1c Allowed > States 2 > 1:d=0; cons=1; prod=0; > 1:d=0; cons=1; prod=1; > No > Witnesses > Positive: 0 Negative: 2 > Condition exists (1:d=1 /\ prod=0 /\ cons=1) > Observation spsc-rb+1p1c Never 0 2 > Time spsc-rb+1p1c 0.04 > Hash=b399756d6a1301ca5bda042f32130791 > > Now to my question; In P0 there's an smp_mb(). Without that, the d==1 > can be observed from P1 (consumer): > > $ herd7 -conf linux-kernel.cfg litmus-tests/spsc-rb+1p1c.litmus > Test spsc-rb+1p1c Allowed > States 3 > 1:d=0; cons=1; prod=0; > 1:d=0; cons=1; prod=1; > 1:d=1; cons=1; prod=0; > Ok > Witnesses > Positive: 1 Negative: 2 > Condition exists (1:d=1 /\ prod=0 /\ cons=1) > Observation spsc-rb+1p1c Sometimes 1 2 > Time spsc-rb+1p1c 0.04 > Hash=0047fc21fa77da9a9aee15e35ec367ef > > In commit c7f2e3cd6c1f ("perf: Optimize ring-buffer write by depending > on control dependencies") removes the corresponding smp_mb(), and also > the circular buffer in circular-buffers.t
[PATCH 1/1] tools headers: Update syscall.tbl files to support mount_setattr
To pick the changes from: 9caccd41541a6f7d ("fs: introduce MOUNT_ATTR_IDMAP") This adds this new syscall to the tables used by tools such as 'perf trace', so that one can specify it by name and have it filtered, etc. Addressing these perf build warnings: Warning: Kernel ABI header at 'tools/perf/arch/x86/entry/syscalls/syscall_64.tbl' differs from latest version at 'arch/x86/entry/syscalls/syscall_64.tbl' diff -u tools/perf/arch/x86/entry/syscalls/syscall_64.tbl arch/x86/entry/syscalls/syscall_64.tbl Warning: Kernel ABI header at 'tools/perf/arch/powerpc/entry/syscalls/syscall.tbl' differs from latest version at 'arch/powerpc/kernel/syscalls/syscall.tbl' diff -u tools/perf/arch/powerpc/entry/syscalls/syscall.tbl arch/powerpc/kernel/syscalls/syscall.tbl Warning: Kernel ABI header at 'tools/perf/arch/s390/entry/syscalls/syscall.tbl' differs from latest version at 'arch/s390/kernel/syscalls/syscall.tbl' diff -u tools/perf/arch/s390/entry/syscalls/syscall.tbl arch/s390/kernel/syscalls/syscall.tbl Cc: Adrian Hunter Cc: Christian Brauner Cc: Ian Rogers Cc: Jiri Olsa Cc: Namhyung Kim Signed-off-by: Arnaldo Carvalho de Melo --- tools/include/uapi/linux/mount.h | 16 .../perf/arch/powerpc/entry/syscalls/syscall.tbl | 1 + tools/perf/arch/s390/entry/syscalls/syscall.tbl | 1 + .../perf/arch/x86/entry/syscalls/syscall_64.tbl | 1 + 4 files changed, 19 insertions(+) diff --git a/tools/include/uapi/linux/mount.h b/tools/include/uapi/linux/mount.h index dd8306ea336c19b6..e6524ead2b7b9ead 100644 --- a/tools/include/uapi/linux/mount.h +++ b/tools/include/uapi/linux/mount.h @@ -1,6 +1,8 @@ #ifndef _UAPI_LINUX_MOUNT_H #define _UAPI_LINUX_MOUNT_H +#include + /* * These are the fs-independent mount-flags: up to 32 flags are supported * @@ -117,5 +119,19 @@ enum fsconfig_command { #define MOUNT_ATTR_NOATIME 0x0010 /* - Do not update access times. */ #define MOUNT_ATTR_STRICTATIME 0x0020 /* - Always perform atime updates */ #define MOUNT_ATTR_NODIRATIME 0x0080 /* Do not update directory access times */ +#define MOUNT_ATTR_IDMAP 0x0010 /* Idmap mount to @userns_fd in struct mount_attr. */ + +/* + * mount_setattr() + */ +struct mount_attr { + __u64 attr_set; + __u64 attr_clr; + __u64 propagation; + __u64 userns_fd; +}; + +/* List of all mount_attr versions. */ +#define MOUNT_ATTR_SIZE_VER0 32 /* sizeof first published struct */ #endif /* _UAPI_LINUX_MOUNT_H */ diff --git a/tools/perf/arch/powerpc/entry/syscalls/syscall.tbl b/tools/perf/arch/powerpc/entry/syscalls/syscall.tbl index 96b2157f03719b59..0b2480cf3e4793bd 100644 --- a/tools/perf/arch/powerpc/entry/syscalls/syscall.tbl +++ b/tools/perf/arch/powerpc/entry/syscalls/syscall.tbl @@ -521,3 +521,4 @@ 439common faccessat2 sys_faccessat2 440common process_madvise sys_process_madvise 441common epoll_pwait2sys_epoll_pwait2 compat_sys_epoll_pwait2 +442common mount_setattr sys_mount_setattr diff --git a/tools/perf/arch/s390/entry/syscalls/syscall.tbl b/tools/perf/arch/s390/entry/syscalls/syscall.tbl index d443423495e565e4..3abef2144dac79b6 100644 --- a/tools/perf/arch/s390/entry/syscalls/syscall.tbl +++ b/tools/perf/arch/s390/entry/syscalls/syscall.tbl @@ -444,3 +444,4 @@ 439 commonfaccessat2 sys_faccessat2 sys_faccessat2 440 commonprocess_madvise sys_process_madvise sys_process_madvise 441 commonepoll_pwait2sys_epoll_pwait2 compat_sys_epoll_pwait2 +442 commonmount_setattr sys_mount_setattr sys_mount_setattr diff --git a/tools/perf/arch/x86/entry/syscalls/syscall_64.tbl b/tools/perf/arch/x86/entry/syscalls/syscall_64.tbl index 78672124d28be0da..7bf01cbe582f03bc 100644 --- a/tools/perf/arch/x86/entry/syscalls/syscall_64.tbl +++ b/tools/perf/arch/x86/entry/syscalls/syscall_64.tbl @@ -363,6 +363,7 @@ 439common faccessat2 sys_faccessat2 440common process_madvise sys_process_madvise 441common epoll_pwait2sys_epoll_pwait2 +442common mount_setattr sys_mount_setattr # # Due to a historical design error, certain syscalls are numbered differently -- 2.29.2
Re: RFC: sysfs node for Secondary PCI bus reset (PCIe Hot Reset)
On Mon, 1 Mar 2021 14:28:17 -0600 Bjorn Helgaas wrote: > [+cc Alex, reset expert] > > On Mon, Mar 01, 2021 at 06:12:21PM +0100, Pali Rohár wrote: > > Hello! > > > > PCIe card can be reset via in-band Hot Reset signal which can be > > triggered by PCIe bridge via Secondary Bus Reset bit in PCI config > > space. > > > > Kernel already exports sysfs node "reset" for triggering Functional > > Reset of particular function of PCI device. But in some cases Functional > > Reset is not enough and Hot Reset is required. > > > > Following RFC patch exports sysfs node "reset_bus" for PCI bridges which > > triggers Secondary Bus Reset and therefore for PCIe bridges it resets > > connected PCIe card. > > > > What do you think about it? > > > > Currently there is userspace script which can trigger PCIe Hot Reset by > > modifying PCI config space from userspace: > > > > https://alexforencich.com/wiki/en/pcie/hot-reset-linux > > > > But because kernel already provides way how to trigger Functional Reset > > it could provide also way how to trigger PCIe Hot Reset. What that script does and what this does, or what the existing reset attribute does, are very different. The script finds the upstream bridge for a given device, removes the device (ignoring that more than one device might be affected by the bus reset), uses setpci to trigger a secondary bus reset, then rescans devices. The below only triggers the secondary bus reset, neither saving and restoring affected device state like the existing function level reset attribute, nor removing and rescanning as the script does. It simply leaves an entire hierarchy of PCI devices entirely un-programmed yet still has struct pci_devs attached to them for untold future misery. In fact, for the case of a single device affected by the bus reset, as intended by the script, the existing reset attribute will already do that if the device supports no other reset mechanism. There's actually a running LFX mentorship project that aims to allow the user to control the type of reset performed by the existing reset attribute such that a user could force the bus reset behavior over other reset methods. There might be some justification for an attribute that actually implements the referenced script correctly, perhaps in kernel we could avoid races with bus rescans, but simply triggering an SBR to quietly de-program all downstream devices with no state restore or device rescan is not it. Any affected device would be unusable. Was this tested? Thanks, Alex > > diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c > > index 50fcb62d59b5..f5e11c589498 100644 > > --- a/drivers/pci/pci-sysfs.c > > +++ b/drivers/pci/pci-sysfs.c > > @@ -1321,6 +1321,30 @@ static ssize_t reset_store(struct device *dev, > > struct device_attribute *attr, > > > > static DEVICE_ATTR(reset, 0200, NULL, reset_store); > > > > +static ssize_t reset_bus_store(struct device *dev, struct device_attribute > > *attr, > > + const char *buf, size_t count) > > +{ > > + struct pci_dev *pdev = to_pci_dev(dev); > > + unsigned long val; > > + ssize_t result = kstrtoul(buf, 0, &val); > > + > > + if (result < 0) > > + return result; > > + > > + if (val != 1) > > + return -EINVAL; > > + > > + pm_runtime_get_sync(dev); > > + result = pci_bridge_secondary_bus_reset(pdev); > > + pm_runtime_put(dev); > > + if (result < 0) > > + return result; > > + > > + return count; > > +} > > + > > +static DEVICE_ATTR(reset_bus, 0200, NULL, reset_bus_store); > > + > > static int pci_create_capabilities_sysfs(struct pci_dev *dev) > > { > > int retval; > > @@ -1332,8 +1356,15 @@ static int pci_create_capabilities_sysfs(struct > > pci_dev *dev) > > if (retval) > > goto error; > > } > > + if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) { > > + retval = device_create_file(&dev->dev, &dev_attr_reset_bus); > > + if (retval) > > + goto error_reset_bus; > > + } > > return 0; > > > > +error_reset_bus: > > + device_remove_file(&dev->dev, &dev_attr_reset); > > error: > > pcie_vpd_remove_sysfs_dev_files(dev); > > return retval; > > @@ -1414,6 +1445,8 @@ static void pci_remove_capabilities_sysfs(struct > > pci_dev *dev) > > device_remove_file(&dev->dev, &dev_attr_reset); > > dev->reset_fn = 0; > > } > > + if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) > > + device_remove_file(&dev->dev, &dev_attr_reset_bus); > > } > > > > /** >
[PATCH] Leds: made enum led_brightness into typedef
In TODO it was written: * Get rid of enum led_brightness It is really an integer, as maximum is configurable. Get rid of it, or make it into typedef or something. So I made it into typedef. Signed-off-by: Antoni Przybylik --- drivers/leds/TODO | 5 drivers/leds/blink/leds-lgm-sso.c | 6 ++--- drivers/leds/flash/leds-rt8515.c | 2 +- drivers/leds/led-class-multicolor.c | 2 +- drivers/leds/led-triggers.c | 2 +- drivers/leds/leds-88pm860x.c | 2 +- drivers/leds/leds-aat1290.c | 8 +++ drivers/leds/leds-acer-a500.c | 2 +- drivers/leds/leds-adp5520.c | 2 +- drivers/leds/leds-an30259a.c | 2 +- drivers/leds/leds-apu.c | 4 ++-- drivers/leds/leds-ariel.c | 4 ++-- drivers/leds/leds-as3645a.c | 4 ++-- drivers/leds/leds-asic3.c | 2 +- drivers/leds/leds-aw2013.c| 2 +- drivers/leds/leds-bcm6328.c | 2 +- drivers/leds/leds-bcm6358.c | 2 +- drivers/leds/leds-bd2802.c| 2 +- drivers/leds/leds-blinkm.c| 8 +++ drivers/leds/leds-clevo-mail.c| 2 +- drivers/leds/leds-cobalt-qube.c | 2 +- drivers/leds/leds-cobalt-raq.c| 4 ++-- drivers/leds/leds-cpcap.c | 2 +- drivers/leds/leds-cr0014114.c | 2 +- drivers/leds/leds-da903x.c| 2 +- drivers/leds/leds-da9052.c| 4 ++-- drivers/leds/leds-dac124s085.c| 2 +- drivers/leds/leds-el15203000.c| 2 +- drivers/leds/leds-fsg.c | 12 +- drivers/leds/leds-gpio.c | 4 ++-- drivers/leds/leds-hp6xx.c | 4 ++-- drivers/leds/leds-ip30.c | 2 +- drivers/leds/leds-ipaq-micro.c| 2 +- drivers/leds/leds-is31fl319x.c| 2 +- drivers/leds/leds-is31fl32xx.c| 2 +- drivers/leds/leds-ktd2692.c | 6 ++--- drivers/leds/leds-lm3530.c| 4 ++-- drivers/leds/leds-lm3532.c| 2 +- drivers/leds/leds-lm3533.c| 4 ++-- drivers/leds/leds-lm355x.c| 6 ++--- drivers/leds/leds-lm3601x.c | 2 +- drivers/leds/leds-lm36274.c | 2 +- drivers/leds/leds-lm3642.c| 6 ++--- drivers/leds/leds-lm3692x.c | 4 ++-- drivers/leds/leds-lm3697.c| 2 +- drivers/leds/leds-locomo.c| 6 ++--- drivers/leds/leds-lp3944.c| 4 ++-- drivers/leds/leds-lp3952.c| 2 +- drivers/leds/leds-lp50xx.c| 2 +- drivers/leds/leds-lp55xx-common.c | 4 ++-- drivers/leds/leds-lp8788.c| 2 +- drivers/leds/leds-lp8860.c| 2 +- drivers/leds/leds-lt3593.c| 2 +- drivers/leds/leds-max77650.c | 2 +- drivers/leds/leds-max77693.c | 2 +- drivers/leds/leds-max8997.c | 4 ++-- drivers/leds/leds-mc13783.c | 2 +- drivers/leds/leds-menf21bmc.c | 2 +- drivers/leds/leds-mlxcpld.c | 4 ++-- drivers/leds/leds-mlxreg.c| 8 +++ drivers/leds/leds-mt6323.c| 10 drivers/leds/leds-net48xx.c | 2 +- drivers/leds/leds-netxbig.c | 2 +- drivers/leds/leds-nic78bx.c | 4 ++-- drivers/leds/leds-ns2.c | 4 ++-- drivers/leds/leds-ot200.c | 2 +- drivers/leds/leds-pca9532.c | 4 ++-- drivers/leds/leds-pca955x.c | 2 +- drivers/leds/leds-pca963x.c | 4 ++-- drivers/leds/leds-pm8058.c| 6 ++--- drivers/leds/leds-powernv.c | 8 +++ drivers/leds/leds-pwm.c | 2 +- drivers/leds/leds-rb532.c | 4 ++-- drivers/leds/leds-regulator.c | 4 ++-- drivers/leds/leds-s3c24xx.c | 2 +- drivers/leds/leds-sc27xx-bltc.c | 4 ++-- drivers/leds/leds-sgm3140.c | 2 +- drivers/leds/leds-spi-byte.c | 2 +- drivers/leds/leds-ss4200.c| 2 +- drivers/leds/leds-sunfire.c | 18 +++ drivers/leds/leds-syscon.c| 2 +- drivers/leds/leds-tca6507.c | 2 +- drivers/leds/leds-tlc591xx.c | 2 +- drivers/leds/leds-tps6105x.c | 2 +- drivers/leds/leds-turris-omnia.c | 2 +- drivers/leds/leds-wm831x-status.c | 4 ++-- drivers/leds/leds-wm8350.c| 2 +- drivers/leds/leds-wrap.c | 6 ++--- drivers/leds/trigger/ledtrig-audio.c | 6 ++--- drivers/leds/trigger/ledtrig-camera.c | 4 ++-- drivers/leds/uleds.c | 2 +- include/linux/leds.h | 33 +-- 92 files changed, 174 insertions(+), 180 deletions(-) diff --git a/drivers/leds/TODO b/drivers/leds/TODO index bfa60fa1d812..7ca785d0ff77 100644 --- a/drivers/leds/TODO +++ b/drivers/leds/TODO @@ -1,11 +1,6 @@ -*- org -*- * On/off LEDs should have max_brightness of 1 -* Get rid of enum led_brig
Re: Build regressions/improvements in v5.12-rc1
Hi Alex, On Tue, Mar 2, 2021 at 8:30 PM Alex Deucher wrote: > On Mon, Mar 1, 2021 at 9:21 AM Geert Uytterhoeven > wrote: > > On Mon, 1 Mar 2021, Geert Uytterhoeven wrote: > > > Below is the list of build error/warning regressions/improvements in > > > v5.12-rc1[1] compared to v5.11[2]. > > > > > > Summarized: > > > - build errors: +2/-0 > > > > > [1] > > > http://kisskb.ellerman.id.au/kisskb/branch/linus/head/fe07bfda2fb9cdef8a4d4008a409bb02f35f1bd8/ > > > (all 192 configs) > > > [2] > > > http://kisskb.ellerman.id.au/kisskb/branch/linus/head/f40ddce88593482919761f74910f42f4b84c004b/ > > > (all 192 configs) > > > > > > > > > *** ERRORS *** > > > > > > 2 error regressions: > > > + > > > /kisskb/src/drivers/gpu/drm/amd/amdgpu/../display/dc/calcs/dcn_calcs.c: > > > error: implicit declaration of function 'disable_kernel_vsx' > > > [-Werror=implicit-function-declaration]: => 674:2 > > > + > > > /kisskb/src/drivers/gpu/drm/amd/amdgpu/../display/dc/calcs/dcn_calcs.c: > > > error: implicit declaration of function 'enable_kernel_vsx' > > > [-Werror=implicit-function-declaration]: => 638:2 > > > > powerpc-gcc4.9/ppc64_book3e_allmodconfig > > > > This was fixed in v5.11-rc1, but reappeared in v5.12-rc1? > > Do you know what fixed in for 5.11? I guess for PPC64 we depend on > CONFIG_VSX? Looking at the kisskb build logs for v5.11*, it seems compilation never got to drivers/gpu/drm/ due to internal compiler errors that weren't caught by my scripts. So the errors listed above were not really fixed. Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
Re: XDP socket rings, and LKMM litmus tests
On Tue, Mar 02, 2021 at 11:57:58AM -0800, Paul E. McKenney wrote: > On Tue, Mar 02, 2021 at 07:46:27PM +0100, Björn Töpel wrote: > > Hi! > > > > Firstly; The long Cc-list is to reach the LKMM-folks. > > > > Some background; the XDP sockets use a ring-buffer to communicate > > between the kernel and userland. It's a > > single-consumer/single-producer ring, and described in > > net/xdp/xsk_queue.h. > > > > --8<--- > > /* The structure of the shared state of the rings are the same as the > > * ring buffer in kernel/events/ring_buffer.c. For the Rx and completion > > * ring, the kernel is the producer and user space is the consumer. For > > * the Tx and fill rings, the kernel is the consumer and user space is > > * the producer. > > * > > * producer consumer > > * > > * if (LOAD ->consumer) { LOAD ->producer > > *(A) smp_rmb() (C) > > *STORE $data LOAD $data > > *smp_wmb() (B) smp_mb()(D) > > *STORE ->producer STORE ->consumer > > * } > > * > > * (A) pairs with (D), and (B) pairs with (C). > > ... > > -->8--- > > > > I'd like to replace the smp_{r,w,}mb() barriers with acquire-release > > semantics [1], without breaking existing userspace applications. > > > > So, I figured I'd use herd7 and the LKMM model to build a litmus test > > for the barrier version, then for the acquire-release version, and > > finally permutations of both. > > > > The idea is to use a one element ring, with a state machine outlined > > in the litmus test. > > > > The basic test for the existing smp_{r,w,}mb() barriers looks like: > > > > $ cat spsc-rb+1p1c.litmus > > C spsc-rb+1p1c > > > > // Stupid one entry ring: > > // prod cons allowed action prod cons > > //00 => prod => 10 > > //01 => cons => 00 > > //10 => cons => 11 > > //11 => prod => 01 > > > > { prod = 1; } > > > > // Here, we start at prod==1,cons==0, data==0, i.e. producer has > > // written data=0, so from here only the consumer can start, and should > > // consume data==0. Afterwards, producer can continue and write 1 to > > // data. Can we enter state prod==0, cons==1, but consumer observerd > > // the write of 1? > > > > P0(int *prod, int *cons, int *data) > > { > > int p; > > int c; > > int cond = 0; > > > > p = READ_ONCE(*prod); > > c = READ_ONCE(*cons); > > if (p == 0) > > if (c == 0) > > cond = 1; > > if (p == 1) > > if (c == 1) > > cond = 1; > > > > if (cond) { > > smp_mb(); > > WRITE_ONCE(*data, 1); > > smp_wmb(); > > WRITE_ONCE(*prod, p ^ 1); > > } > > } > > > > P1(int *prod, int *cons, int *data) > > { > > int p; > > int c; > > int d = -1; > > int cond = 0; > > > > p = READ_ONCE(*prod); > > c = READ_ONCE(*cons); > > if (p == 1) > > if (c == 0) > > cond = 1; > > if (p == 0) > > if (c == 1) > > cond = 1; > > > > if (cond == 1) { > > smp_rmb(); > > d = READ_ONCE(*data); > > smp_mb(); > > WRITE_ONCE(*cons, c ^ 1); > > } > > } > > Before digging in too deeply, does the following simplification > still capture your intent? > > P0(int *prod, int *cons, int *data) > { > int p; > int cond = 0; > > p = READ_ONCE(*prod); > if (p == READ_ONCE(*cons)) > cond = 1; > if (cond) { > smp_mb(); > WRITE_ONCE(*data, 1); > smp_wmb(); > WRITE_ONCE(*prod, p ^ 1); > } > } > > P1(int *prod, int *cons, int *data) > { > int c; > int d = -1; > int cond = 0; > > c = READ_ONCE(*cons); > if (READ_ONCE(*prod) == c) > cond = 1; > > if (cond == 1) { > smp_rmb(); > d = READ_ONCE(*data); > smp_mb(); > WRITE_ONCE(*cons, c ^ 1); > } > } And if the answer is "yes", how about this one? P0(int *prod, int *cons, int *data) { int p; p = READ_ONCE(*prod); if (p == READ_ONCE(*cons)) { WRITE_ONCE(*data, 1); smp_wmb(); WRITE_ONCE(*prod, p ^ 1); } } P1(int *prod, int *cons, int *data) { int c; int d = -1; c = READ_ONCE(*cons); if (READ_ONCE(*prod) == c) { smp_rmb(); d = READ_ONCE(*data); smp_mb(); WRITE_ONCE(*cons, c ^ 1); } } Thanx, Paul > > exists( 1:d=1 /\ prod=0 /\ cons=1 ); > > > > -- > > > > The weird state changing if-statements is because that I didn't get > > '&&' and '||' to work with herd. > > > > When this is run: > > > > $ herd7 -conf linux-kernel.cfg litmus-tests/spsc-rb+1p1c.litmus > > Test spsc-rb+1p1c Allowed > > States 2 > > 1:d=0; cons=1; prod=0; > > 1:d=0; cons=1; prod=1; > > No > > Wi
[PATCH] ibmvnic: Fix possibly uninitialized old_num_tx_queues variable warning.
GCC 7.5 reports: ../drivers/net/ethernet/ibm/ibmvnic.c: In function 'ibmvnic_reset_init': ../drivers/net/ethernet/ibm/ibmvnic.c:5373:51: warning: 'old_num_tx_queues' may be used uninitialized in this function [-Wmaybe-uninitialized] ../drivers/net/ethernet/ibm/ibmvnic.c:5373:6: warning: 'old_num_rx_queues' may be used uninitialized in this function [-Wmaybe-uninitialized] The variable is initialized only if(reset) and used only if(reset && something) so this is a false positive. However, there is no reason to not initialize the variables unconditionally avoiding the warning. Fixes: 635e442f4a48 ("ibmvnic: merge ibmvnic_reset_init and ibmvnic_init") Signed-off-by: Michal Suchanek --- drivers/net/ethernet/ibm/ibmvnic.c | 8 +++- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c index 118a4bd3f877..3bad762083c5 100644 --- a/drivers/net/ethernet/ibm/ibmvnic.c +++ b/drivers/net/ethernet/ibm/ibmvnic.c @@ -5219,16 +5219,14 @@ static int ibmvnic_reset_init(struct ibmvnic_adapter *adapter, bool reset) { struct device *dev = &adapter->vdev->dev; unsigned long timeout = msecs_to_jiffies(2); - u64 old_num_rx_queues, old_num_tx_queues; + u64 old_num_rx_queues = adapter->req_rx_queues; + u64 old_num_tx_queues = adapter->req_tx_queues; int rc; adapter->from_passive_init = false; - if (reset) { - old_num_rx_queues = adapter->req_rx_queues; - old_num_tx_queues = adapter->req_tx_queues; + if (reset) reinit_completion(&adapter->init_done); - } adapter->init_done_rc = 0; rc = ibmvnic_send_crq_init(adapter); -- 2.26.2
f2fs_convert_inline_inode causing rebalance based on random uninitialized value in dn.node_changed
Hi, Static analysis on linux-next detected a potential uninitialized variable dn.node_changed that does not get set when a call to f2fs_get_node_page() fails. This uninitialized value gets used in the call to f2fs_balance_fs() that may or not may not balances dirty node and dentry pages depending on the uninitialized state of the variable. I believe the issue was introduced by commit: commit 2a3407607028f7c780f1c20faa4e922bf631d340 Author: Jaegeuk Kim Date: Tue Dec 22 13:23:35 2015 -0800 f2fs: call f2fs_balance_fs only when node was changed The analysis is a follows: 184 int f2fs_convert_inline_inode(struct inode *inode) 185 { 186struct f2fs_sb_info *sbi = F2FS_I_SB(inode); 1. var_decl: Declaring variable dn without initializer. 187struct dnode_of_data dn; NOTE dn is not initialized here. 188struct page *ipage, *page; 189int err = 0; 190 2. Condition !f2fs_has_inline_data(inode), taking false branch. 3. Condition f2fs_hw_is_readonly(sbi), taking false branch. 4. Condition f2fs_readonly(sbi->sb), taking false branch. 191if (!f2fs_has_inline_data(inode) || 192f2fs_hw_is_readonly(sbi) || f2fs_readonly(sbi->sb)) 193return 0; 194 195err = dquot_initialize(inode); 5. Condition err, taking false branch. 196if (err) 197return err; 198 199page = f2fs_grab_cache_page(inode->i_mapping, 0, false); 6. Condition !page, taking false branch. 200if (!page) 201return -ENOMEM; 202 203f2fs_lock_op(sbi); 204 205ipage = f2fs_get_node_page(sbi, inode->i_ino); 7. Condition IS_ERR(ipage), taking true branch. 206if (IS_ERR(ipage)) { 207err = PTR_ERR(ipage); 8. Jumping to label out. 208goto out; 209} 210 NOTE: set_new_dnode memset's dn so sets the flag to false, but we don't get to this memset if IS_ERR(ipage) above is true. 211set_new_dnode(&dn, inode, ipage, ipage, 0); 212 213if (f2fs_has_inline_data(inode)) 214err = f2fs_convert_inline_page(&dn, page); 215 216f2fs_put_dnode(&dn); 217 out: 218f2fs_unlock_op(sbi); 219 220f2fs_put_page(page, 1); 221 Uninitialized scalar variable: 9. uninit_use_in_call: Using uninitialized value dn.node_changed when calling f2fs_balance_fs. 222f2fs_balance_fs(sbi, dn.node_changed); 223 224return err; 225 } I think a suitable fix will be to set dn.node_changed to false on in line 207-208 but I'm concerned if I'm missing something subtle to the rebalancing if I do this. Comments? Colin
[PATCH] powerpc/fadump: Mark fadump_calculate_reserve_size as __init
If fadump_calculate_reserve_size() is not inlined, there is a modpost warning: WARNING: modpost: vmlinux.o(.text+0x5196c): Section mismatch in reference from the function fadump_calculate_reserve_size() to the function .init.text:parse_crashkernel() The function fadump_calculate_reserve_size() references the function __init parse_crashkernel(). This is often because fadump_calculate_reserve_size lacks a __init annotation or the annotation of parse_crashkernel is wrong. fadump_calculate_reserve_size() calls parse_crashkernel(), which is marked as __init and fadump_calculate_reserve_size() is called from within fadump_reserve_mem(), which is also marked as __init. Mark fadump_calculate_reserve_size() as __init to fix the section mismatch. Additionally, remove the inline keyword as it is not necessary to inline this function; the compiler is still free to do so if it feels it is worthwhile since commit 889b3c1245de ("compiler: remove CONFIG_OPTIMIZE_INLINING entirely"). Fixes: 11550dc0a00b ("powerpc/fadump: reuse crashkernel parameter for fadump memory reservation") Link: https://github.com/ClangBuiltLinux/linux/issues/1300 Signed-off-by: Nathan Chancellor --- Send while streaming at https://www.twitch.tv/nathanchance :P arch/powerpc/kernel/fadump.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/powerpc/kernel/fadump.c b/arch/powerpc/kernel/fadump.c index 8482739d42f3..eddf362caedc 100644 --- a/arch/powerpc/kernel/fadump.c +++ b/arch/powerpc/kernel/fadump.c @@ -292,7 +292,7 @@ static void fadump_show_config(void) * that is required for a kernel to boot successfully. * */ -static inline u64 fadump_calculate_reserve_size(void) +static __init u64 fadump_calculate_reserve_size(void) { u64 base, size, bootmem_min; int ret; base-commit: 5c88a17e15795226b56d83f579cbb9b7a4864f79 -- 2.31.0.rc0.75.gec125d1bc1
Re: [PATCH v2 02/12] pinctrl: add a pincontrol driver for BCM6328
Am 2021-03-02 20:16, schrieb Álvaro Fernández Rojas: Add a pincontrol driver for BCM6328. BCM628 supports muxing 32 pins as GPIOs, as LEDs for the integrated LED controller, or various other functions. Its pincontrol mux registers also control other aspects, like switching the second USB port between host and device mode. Signed-off-by: Álvaro Fernández Rojas Signed-off-by: Jonas Gorski --- v2: switch to GPIO_REGMAP drivers/pinctrl/bcm/Kconfig | 13 + drivers/pinctrl/bcm/Makefile | 1 + drivers/pinctrl/bcm/pinctrl-bcm6328.c | 481 ++ 3 files changed, 495 insertions(+) create mode 100644 drivers/pinctrl/bcm/pinctrl-bcm6328.c diff --git a/drivers/pinctrl/bcm/Kconfig b/drivers/pinctrl/bcm/Kconfig index 0ed14de0134c..76728f097c25 100644 --- a/drivers/pinctrl/bcm/Kconfig +++ b/drivers/pinctrl/bcm/Kconfig @@ -29,6 +29,19 @@ config PINCTRL_BCM2835 help Say Y here to enable the Broadcom BCM2835 GPIO driver. +config PINCTRL_BCM6328 + bool "Broadcom BCM6328 GPIO driver" + depends on OF_GPIO && (BMIPS_GENERIC || COMPILE_TEST) + select GPIO_REGMAP + select GPIOLIB_IRQCHIP + select IRQ_DOMAIN_HIERARCHY + select PINMUX + select PINCONF + select GENERIC_PINCONF select GPIO_REGMAP ? + default BMIPS_GENERIC + help + Say Y here to enable the Broadcom BCM6328 GPIO driver. + config PINCTRL_IPROC_GPIO bool "Broadcom iProc GPIO (with PINCONF) driver" depends on OF_GPIO && (ARCH_BCM_IPROC || COMPILE_TEST) diff --git a/drivers/pinctrl/bcm/Makefile b/drivers/pinctrl/bcm/Makefile index 79d5e49fdd9a..7e7c6e25b26d 100644 --- a/drivers/pinctrl/bcm/Makefile +++ b/drivers/pinctrl/bcm/Makefile @@ -3,6 +3,7 @@ obj-$(CONFIG_PINCTRL_BCM281XX) += pinctrl-bcm281xx.o obj-$(CONFIG_PINCTRL_BCM2835) += pinctrl-bcm2835.o +obj-$(CONFIG_PINCTRL_BCM6328) += pinctrl-bcm6328.o obj-$(CONFIG_PINCTRL_IPROC_GPIO) += pinctrl-iproc-gpio.o obj-$(CONFIG_PINCTRL_CYGNUS_MUX) += pinctrl-cygnus-mux.o obj-$(CONFIG_PINCTRL_NS) += pinctrl-ns.o diff --git a/drivers/pinctrl/bcm/pinctrl-bcm6328.c b/drivers/pinctrl/bcm/pinctrl-bcm6328.c new file mode 100644 index ..f2b1a14e7903 --- /dev/null +++ b/drivers/pinctrl/bcm/pinctrl-bcm6328.c [..] +static int bcm6328_reg_mask_xlate(struct gpio_regmap *gpio, + unsigned int base, unsigned int offset, + unsigned int *reg, unsigned int *mask) +{ + unsigned int line = offset % gpio->ngpio_per_reg; + unsigned int stride = offset / gpio->ngpio_per_reg; + + *reg = base - stride * gpio->reg_stride; + *mask = BIT(line); + + return 0; +} How many registers are there? npgio_per_reg is 32 but so is ngpio. So isn't there only one register? And thus, can you use the default gpio_regmap_simple_xlat()? [..] +static int bcm6328_pinctrl_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct gpio_regmap_config grc = {0}; + struct gpio_regmap *gr; + struct bcm6328_pinctrl *pc; + int err; + + pc = devm_kzalloc(dev, sizeof(*pc), GFP_KERNEL); + if (!pc) + return -ENOMEM; + + platform_set_drvdata(pdev, pc); + pc->dev = dev; + + pc->regs = syscon_node_to_regmap(dev->parent->of_node); + if (IS_ERR(pc->regs)) + return PTR_ERR(pc->regs); + + grc.parent = dev; + grc.ngpio = BCM6328_NUM_GPIOS; + grc.ngpio_per_reg = BCM6328_BANK_GPIOS; + grc.regmap = pc->regs; + grc.reg_dat_base = BCM6328_DATA_REG; + grc.reg_dir_out_base = BCM6328_DIROUT_REG; + grc.reg_mask_xlate = bcm6328_reg_mask_xlate; + grc.reg_set_base = BCM6328_DATA_REG; + grc.reg_stride = 4; + + gr = devm_gpio_regmap_register(dev, &grc); + err = PTR_ERR_OR_ZERO(gr); + if (err) { + dev_err(dev, "could not add GPIO chip\n"); + return err; + } + + pc->pctl_desc.name = MODULE_NAME; + pc->pctl_desc.pins = bcm6328_pins; + pc->pctl_desc.npins = ARRAY_SIZE(bcm6328_pins); + pc->pctl_desc.pctlops = &bcm6328_pctl_ops; + pc->pctl_desc.pmxops = &bcm6328_pmx_ops; + pc->pctl_desc.owner = THIS_MODULE; + + pc->pctl_dev = devm_pinctrl_register(dev, &pc->pctl_desc, pc); + if (IS_ERR(pc->pctl_dev)) { + gpiochip_remove(&gr->gpio_chip); + return PTR_ERR(pc->pctl_dev); + } + + pc->gpio_range.name = MODULE_NAME; + pc->gpio_range.npins = BCM6328_NUM_GPIOS; + pc->gpio_range.base = gr->gpio_chip.base; + pc->gpio_range.gc = &gr->gpio_chip; + pinctrl_add_gpio_range(pc->pctl_dev, &pc->gpio_range); Ahh I see. What about adding a new function in gpio-regmap.c: gpio_regmap_pinctrl_add_gpio_range(pc->pctl_dev, &pc->gpio_range)? gpio-regmap should have all the info
Re: exec error: BUG: Bad rss-counter
Ilya Lipnitskiy writes: > On Mon, Mar 1, 2021 at 12:43 PM Eric W. Biederman > wrote: >> >> Ilya Lipnitskiy writes: >> >> > Eric, All, >> > >> > The following error appears when running Linux 5.10.18 on an embedded >> > MIPS mt7621 target: >> > [0.301219] BUG: Bad rss-counter state mm:(ptrval) type:MM_ANONPAGES >> > val:1 >> > >> > Being a very generic error, I started digging and added a stack dump >> > before the BUG: >> > Call Trace: >> > [<80008094>] show_stack+0x30/0x100 >> > [<8033b238>] dump_stack+0xac/0xe8 >> > [<800285e8>] __mmdrop+0x98/0x1d0 >> > [<801a6de8>] free_bprm+0x44/0x118 >> > [<801a86a8>] kernel_execve+0x160/0x1d8 >> > [<800420f4>] call_usermodehelper_exec_async+0x114/0x194 >> > [<80003198>] ret_from_kernel_thread+0x14/0x1c >> > >> > So that's how I got to looking at fs/exec.c and noticed quite a few >> > changes last year. Turns out this message only occurs once very early >> > at boot during the very first call to kernel_execve. current->mm is >> > NULL at this stage, so acct_arg_size() is effectively a no-op. >> >> If you believe this is a new error you could bisect the kernel >> to see which change introduced the behavior you are seeing. >> >> > More digging, and I traced the RSS counter increment to: >> > [<8015adb4>] add_mm_counter_fast+0xb4/0xc0 >> > [<80160d58>] handle_mm_fault+0x6e4/0xea0 >> > [<80158aa4>] __get_user_pages.part.78+0x190/0x37c >> > [<8015992c>] __get_user_pages_remote+0x128/0x360 >> > [<801a6d9c>] get_arg_page+0x34/0xa0 >> > [<801a7394>] copy_string_kernel+0x194/0x2a4 >> > [<801a880c>] kernel_execve+0x11c/0x298 >> > [<800420f4>] call_usermodehelper_exec_async+0x114/0x194 >> > [<80003198>] ret_from_kernel_thread+0x14/0x1c >> > >> > In fact, I also checked vma_pages(bprm->vma) and lo and behold it is set >> > to 1. >> > >> > How is fs/exec.c supposed to handle implied RSS increments that happen >> > due to page faults when discarding the bprm structure? In this case, >> > the bug-generating kernel_execve call never succeeded, it returned -2, >> > but I didn't trace exactly what failed. >> >> Unless I am mistaken any left over pages should be purged by exit_mmap >> which is called by mmput before mmput calls mmdrop. > Good to know. Some more digging and I can say that we hit this error > when trying to unmap PFN 0 (is_zero_pfn(pfn) returns TRUE, > vm_normal_page returns NULL, zap_pte_range does not decrement > MM_ANONPAGES RSS counter). Is my understanding correct that PFN 0 is > usable, but special? Or am I totally off the mark here? It would be good to know if that is the page that get_user_pages_remote returned to copy_string_kernel. The zero page that is always zero, should never be returned when a writable mapping is desired. > Here is the (optimized) stack trace when the counter does not get decremented: > [<8015b078>] vm_normal_page+0x114/0x1a8 > [<8015dc98>] unmap_page_range+0x388/0xacc > [<8015e5a0>] unmap_vmas+0x6c/0x98 > [<80166194>] exit_mmap+0xd8/0x1ac > [<800290c0>] mmput+0x58/0xf8 > [<801a6f8c>] free_bprm+0x2c/0xc4 > [<801a8890>] kernel_execve+0x160/0x1d8 > [<800420e0>] call_usermodehelper_exec_async+0x114/0x194 > [<80003198>] ret_from_kernel_thread+0x14/0x1c > >> >> AKA it looks very very fishy this happens and this does not look like >> an execve error. > I think you are right, I'm probably wrong to bother you. However, > since the thread is already started, let me add linux-mm here :) It happens during exec. I don't mind looking and pointing you a useful direction. >> >> On the other hand it would be good to know why kernel_execve is failing. >> Then the error handling paths could be scrutinized, and we can check to >> see if everything that should happen on an error path does. > I can check on this, but likely it's the init system not doing things > quite in the right order on my platform, or something similar. The > error is ENOENT from do_open_execat(). That does narrow things down considerably. After the error all we do is: Clear in_execve and fs->in_exec. Return from bprm_execve Call free_bprm Which does: if (bprm->mm) { acct_arg_size(bprm, 0); mmput(bprm->mm); } So it really needs to be the mmput that cleans things up.\ I would really verify the correspondence between what get_arg_page returns and what gets freed in mmput if it is not too difficult. I think it should just be a page or two. Eric
Re: [PATCH V8 0/4] dt: Add fdtoverlay rule and statically build unittest
On Mon, Mar 1, 2021 at 10:03 PM Viresh Kumar wrote: > > On 01-03-21, 21:14, Frank Rowand wrote: > > Hi Viresh, > > > > On 3/1/21 12:56 AM, Viresh Kumar wrote: > > > On 12-02-21, 16:48, Viresh Kumar wrote: > > >> Hi, > > >> > > >> This patchset adds a generic rule for applying overlays using fdtoverlay > > >> tool and then updates unittests to get built statically using the same. > > >> > > >> V7->V8: > > >> - Patch 1 is new. > > >> - Platforms need to use dtb-y += foo.dtb instead of overlay-y += > > >> foo.dtb. > > >> - Use multi_depend instead of .SECONDEXPANSION. > > >> - Use dtb-y for unittest instead of overlay-y. > > >> - Rename the commented dtb filess in unittest Makefile as .dtbo. > > >> - Improved Makefile code (I am learning a lot every day :) > > > > > > Ping! > > > > > > > Please respin on 5.12-rc1, and pull in the change you said > > you would make in response to my post v8 comment about the > > v7 patches. > > Yes, I will do that. > > I must have been more explicit about the Ping I believe. It was > more for Masahiro and Rob to see if the kbuild stuff (which is > relatively new) makes sense or not before I respin this.. LGTM, I was mainly waiting on Acks from Masahiro and Frank. Rob
[PATCH] powerpc/prom: Mark identical_pvr_fixup as __init
If identical_pvr_fixup() is not inlined, there are two modpost warnings: WARNING: modpost: vmlinux.o(.text+0x54e8): Section mismatch in reference from the function identical_pvr_fixup() to the function .init.text:of_get_flat_dt_prop() The function identical_pvr_fixup() references the function __init of_get_flat_dt_prop(). This is often because identical_pvr_fixup lacks a __init annotation or the annotation of of_get_flat_dt_prop is wrong. WARNING: modpost: vmlinux.o(.text+0x551c): Section mismatch in reference from the function identical_pvr_fixup() to the function .init.text:identify_cpu() The function identical_pvr_fixup() references the function __init identify_cpu(). This is often because identical_pvr_fixup lacks a __init annotation or the annotation of identify_cpu is wrong. identical_pvr_fixup() calls two functions marked as __init and is only called by a function marked as __init so it should be marked as __init as well. At the same time, remove the inline keywork as it is not necessary to inline this function. The compiler is still free to do so if it feels it is worthwhile since commit 889b3c1245de ("compiler: remove CONFIG_OPTIMIZE_INLINING entirely"). Fixes: 14b3d926a22b ("[POWERPC] 4xx: update 440EP(x)/440GR(x) identical PVR issue workaround") Link: https://github.com/ClangBuiltLinux/linux/issues/1316 Signed-off-by: Nathan Chancellor --- arch/powerpc/kernel/prom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c index 9a4797d1d40d..a8b2d6bfc1ca 100644 --- a/arch/powerpc/kernel/prom.c +++ b/arch/powerpc/kernel/prom.c @@ -267,7 +267,7 @@ static struct feature_property { }; #if defined(CONFIG_44x) && defined(CONFIG_PPC_FPU) -static inline void identical_pvr_fixup(unsigned long node) +static __init void identical_pvr_fixup(unsigned long node) { unsigned int pvr; const char *model = of_get_flat_dt_prop(node, "model", NULL); base-commit: 5c88a17e15795226b56d83f579cbb9b7a4864f79 -- 2.31.0.rc0.75.gec125d1bc1
RE: [PATCH] mm/compaction: remove unused variable sysctl_compact_memory
> -Original Message- > From: pintu=codeaurora@mg.codeaurora.org > On Behalf Of Pintu Kumar > Sent: Tuesday, March 2, 2021 9:56 AM > To: linux-kernel@vger.kernel.org; a...@linux-foundation.org; linux- > m...@kvack.org; linux-fsde...@vger.kernel.org; pi...@codeaurora.org; > iamjoonsoo@lge.com; sh_...@163.com; mateusznos...@gmail.com; > b...@redhat.com; Nitin Gupta ; vba...@suse.cz; > yzai...@google.com; keesc...@chromium.org; mcg...@kernel.org; > mgor...@techsingularity.net > Cc: pintu.p...@gmail.com > Subject: [PATCH] mm/compaction: remove unused variable > sysctl_compact_memory > > External email: Use caution opening links or attachments > > > The sysctl_compact_memory is mostly unsed in mm/compaction.c It just acts > as a place holder for sysctl. > > Thus we can remove it from here and move the declaration directly in > kernel/sysctl.c itself. > This will also eliminate the extern declaration from header file. I prefer keeping the existing pattern of listing all compaction related tunables together in compaction.h: extern int sysctl_compact_memory; extern unsigned int sysctl_compaction_proactiveness; extern int sysctl_extfrag_threshold; extern int sysctl_compact_unevictable_allowed; > No functionality is broken or changed this way. > > Signed-off-by: Pintu Kumar > Signed-off-by: Pintu Agarwal > --- > include/linux/compaction.h | 1 - > kernel/sysctl.c| 1 + > mm/compaction.c| 3 --- > 3 files changed, 1 insertion(+), 4 deletions(-) > > diff --git a/include/linux/compaction.h b/include/linux/compaction.h index > ed4070e..4221888 100644 > --- a/include/linux/compaction.h > +++ b/include/linux/compaction.h > @@ -81,7 +81,6 @@ static inline unsigned long compact_gap(unsigned int > order) } > > #ifdef CONFIG_COMPACTION > -extern int sysctl_compact_memory; > extern unsigned int sysctl_compaction_proactiveness; extern int > sysctl_compaction_handler(struct ctl_table *table, int write, > void *buffer, size_t *length, loff_t *ppos); diff > --git > a/kernel/sysctl.c b/kernel/sysctl.c index c9fbdd8..66aff21 100644 > --- a/kernel/sysctl.c > +++ b/kernel/sysctl.c > @@ -198,6 +198,7 @@ static int max_sched_tunable_scaling = > SCHED_TUNABLESCALING_END-1; #ifdef CONFIG_COMPACTION static int > min_extfrag_threshold; static int max_extfrag_threshold = 1000; > +static int sysctl_compact_memory; > #endif > > #endif /* CONFIG_SYSCTL */ > diff --git a/mm/compaction.c b/mm/compaction.c index 190ccda..ede2886 > 100644 > --- a/mm/compaction.c > +++ b/mm/compaction.c > @@ -2650,9 +2650,6 @@ static void compact_nodes(void) > compact_node(nid); > } > > -/* The written value is actually unused, all memory is compacted */ -int > sysctl_compact_memory; > - Please retain this comment for the tunable. -Nitin
Re: [PATCH] perf test: Test case 27 fails on s390 and non-x86 platforms
On 3/2/2021 12:08 PM, Thomas Richter wrote: On 3/2/21 4:23 PM, Liang, Kan wrote: On 3/2/2021 9:48 AM, Thomas Richter wrote: On 3/2/21 3:03 PM, Liang, Kan wrote: + Athira Rajeev On 3/2/2021 8:31 AM, Thomas Richter wrote: Executing perf test 27 fails on s390: [root@t35lp46 perf]# ./perf test -Fv 27 27: Sample parsing --- start --- end Sample parsing: FAILED! [root@t35lp46 perf]# The root cause is commit c7444297fd3769 ("perf test: Support PERF_SAMPLE_WEIGHT_STRUCT") This commit introduced a test case for PERF_SAMPLE_WEIGHT_STRUCT but does not adjust non-x86 weak linkage functions. The error is in test__sample_parsing() --> do_test() Function do_test() defines two structures of type struct perf_sample named sample and sample_out. The first sets member sample.ins_lat = 117 Structure sample_out is constructed dynamically using functions perf_event__synthesize_sample() and evsel__parse_sample(). Both functions have an x86 specific function version which sets member ins_lat. The weak common functions do not set member ins_lat. I don't think Power supports the instruction latency. As a request from Athira Rajeev, I moved the PERF_SAMPLE_WEIGHT_STRUCT to the X86 specific codes. https://lore.kernel.org/lkml/d97fef4f-dd88-4760-885e-9a6161a9b...@linux.vnet.ibm.com/ https://lore.kernel.org/lkml/1612540912-6562-1-git-send-email-kan.li...@linux.intel.com/ I don't think we want to add the ins_lat back in the weak common functions. Could you please update the perf test and don't apply the PERF_SAMPLE_WEIGHT_STRUCT for the non-X86 platform? I used offical linux git tree [root@t35lp46 perf]# git tag | fgrep 5.12 v5.12-rc1 [root@t35lp46 perf]# So this change is in the pipe. I do not plan to revert individual patches. No, we shouldn't revert the patch. I mean can you fix the issue in perf test? Don't test ins_lat or PERF_SAMPLE_WEIGHT_STRUCT for a non-X86 platform. That would be very ugly code. We would end up in conditional compiles like #ifdef __s390x__ #endif and other architectes like ARM/POWER etc come along. This is something I want to avoid. The ins_lat is a model specific variable. Maybe we should move it to the arch specific test. And this fix only touches perf, not the kernel. The patch changes the behavior of the PERF_SAMPLE_WEIGHT. The high 32 bit will be dropped. It should bring some problems if the high 32 bit contains valid information. Later in function samples_same() both data in variable sample and sample_out are compared. The comparison fails because sample.ins_lat is 117 and samples_out.ins_lat is 0, the weak functions never set member ins_lat. Output after: [root@t35lp46 perf]# ./perf test -Fv 27 27: Sample parsing --- start --- end Sample parsing: Ok [root@t35lp46 perf]# Fixes: commit c7444297fd3769 ("perf test: Support PERF_SAMPLE_WEIGHT_STRUCT") I think the regression should start from commit fbefe9c2f87f ("perf tools: Support arch specific PERF_SAMPLE_WEIGHT_STRUCT processing") Thanks, Kan Kan, I do not follow you. Your commit c7444297fd3769d10c7ffb52c81d71503b3e268f adds this line @@ -242,6 +245,7 @@ static int do_test(u64 sample_type, u64 sample_regs, u64 read_format) .cgroup = 114, .data_page_size = 115, .code_page_size = 116, + .ins_lat = 117, And this assignment 117 breaks the test. As mentioned before, member ins_lat is never touched by the weak functions. Here is the timeline for the patches. 1. The commit c7444297fd3769 and other SPR patches are merged at 2021-02-08. At that time, I don't think we have this issue. perf test should work well. Nope, that line above 'ins_lat = 117.' breaks the test. Comment it out and it works well!!! If you revert the commit fbefe9c2f87f, perf test should work well too. The root cause of the issue is that the commit fbefe9c2f87f change the ins_lat to a model-specific variable, but perf test still verify the variable in the generic test. The below patch moves the PERF_SAMPLE_WEIGHT test into a X86 specific test. Does it work for you? --- tools/perf/arch/x86/include/arch-tests.h | 1 + tools/perf/arch/x86/tests/Build| 1 + tools/perf/arch/x86/tests/arch-tests.c | 4 + tools/perf/arch/x86/tests/sample-parsing.c | 125 + tools/perf/tests/sample-parsing.c | 4 - 5 files changed, 131 insertions(+), 4 deletions(-) create mode 100644 tools/perf/arch/x86/tests/sample-parsing.c diff --git a/tools/perf/arch/x86/include/arch-tests.h b/tools/perf/arch/x86/include/arch-tests.h index 6a54b94..0e20f3d 100644 --- a/tools/perf/arch/x86/include/arch-tests.h +++ b/tools/perf/arch/x86/include/arch-tests.h @@ -10,6 +10,7 @@ int test__rdpmc(struct test *test __maybe_unused, int subtest); int test__insn_x86(struct test *test __maybe_unused, int subtest); int test__intel_pt_pkt_decoder(s
Re: [PATCH] swiotlb: Fix type of max_slot
On 3/2/21 12:21 PM, Kunihiko Hayashi wrote: After the refactoring phase, the type of max_slot has changed from unsigned long to unsigned int. The return type of the function get_max_slots() and the 4th argument type of iommu_is_span_boundary() are different from the type of max_slot. Finally, asserts BUG_ON in iommu_is_span_boundary(). Cc: Christoph Hellwig Fixes: 567d877f9a7d ("swiotlb: refactor swiotlb_tbl_map_single") Signed-off-by: Kunihiko Hayashi I think this is all good. Looking at Linus's master I see: 537 unsigned long max_slots = get_max_slots(boundary_mask); ? --- kernel/dma/swiotlb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/dma/swiotlb.c b/kernel/dma/swiotlb.c index 369e4c3..c10e855 100644 --- a/kernel/dma/swiotlb.c +++ b/kernel/dma/swiotlb.c @@ -534,7 +534,7 @@ static int find_slots(struct device *dev, phys_addr_t orig_addr, unsigned long boundary_mask = dma_get_seg_boundary(dev); dma_addr_t tbl_dma_addr = phys_to_dma_unencrypted(dev, io_tlb_start) & boundary_mask; - unsigned int max_slots = get_max_slots(boundary_mask); + unsigned long max_slots = get_max_slots(boundary_mask); unsigned int iotlb_align_mask = dma_get_min_align_mask(dev) & ~(IO_TLB_SIZE - 1); unsigned int nslots = nr_slots(alloc_size), stride;
Re: Why do kprobes and uprobes singlestep?
On Tue, Mar 2, 2021 at 10:38 AM Andy Lutomirski wrote: > > Is there something like a uprobe test suite? How maintained / > actively used is uprobe? uprobe+bpf is heavily used in production. selftests/bpf has only one test for it though. Why are you asking?
Re: XDP socket rings, and LKMM litmus tests
On Tue, 2 Mar 2021 at 20:57, Paul E. McKenney wrote: > > On Tue, Mar 02, 2021 at 07:46:27PM +0100, Björn Töpel wrote: [...] > > Before digging in too deeply, does the following simplification > still capture your intent? > Thanks for having a look, Paul! > P0(int *prod, int *cons, int *data) > { > int p; > int cond = 0; > > p = READ_ONCE(*prod); > if (p == READ_ONCE(*cons)) > cond = 1; With this, yes! > if (cond) { > smp_mb(); > WRITE_ONCE(*data, 1); > smp_wmb(); > WRITE_ONCE(*prod, p ^ 1); > } > } > > P1(int *prod, int *cons, int *data) > { > int c; > int d = -1; > int cond = 0; > > c = READ_ONCE(*cons); > if (READ_ONCE(*prod) == c) > cond = 1; Hmm, this would not be the correct state transition. c==1 && p==1 would set cond to 1, right? I would agree with: c = READ_ONCE(*cons); if (READ_ONCE(*prod) != c) > > if (cond == 1) { > smp_rmb(); > d = READ_ONCE(*data); > smp_mb(); > WRITE_ONCE(*cons, c ^ 1); > } > } > > Thanx, Paul > [...] Björn
Re: [PATCH] mm/memcg: set memcg when split pages
On Tue, 2 Mar 2021, Michal Hocko wrote: > [Cc Johannes for awareness and fixup Nick's email] > > On Tue 02-03-21 01:34:51, Zhou Guanghui wrote: > > When split page, the memory cgroup info recorded in first page is > > not copied to tail pages. In this case, when the tail pages are > > freed, the uncharge operation is not performed. As a result, the > > usage of this memcg keeps increasing, and the OOM may occur. > > > > So, the copying of first page's memory cgroup info to tail pages > > is needed when split page. > > I was not aware that alloc_pages_exact is used for accounted allocations > but git grep told me otherwise so this is not a theoretical one. Both > users (arm64 and s390 kvm) are quite recent AFAICS. split_page is also > used in dma allocator but I got lost in indirection so I have no idea > whether there are any users there. Yes, it's a bit worrying that such a low-level thing as split_page() can now get caught up in memcg accounting, but I suppose that's okay. I feel rather strongly that whichever way it is done, THP splitting and split_page() should use the same interface to memcg. And a look at mem_cgroup_split_huge_fixup() suggests that nowadays there need to be css_get()s too - or better, a css_get_many(). Its #ifdef CONFIG_TRANSPARENT_HUGEPAGE should be removed, rename it mem_cgroup_split_page_fixup(), and take order from caller. Though I've never much liked that separate pass: would it be better page by page, like this copy_page_memcg() does? Though mem_cgroup_disabled() and css_getting make that less appealing. Hugh > > The page itself looks reasonable to me. > > > Signed-off-by: Zhou Guanghui > > Acked-by: Michal Hocko > > Minor nit > > > --- > > include/linux/memcontrol.h | 10 ++ > > mm/page_alloc.c| 4 +++- > > 2 files changed, 13 insertions(+), 1 deletion(-) > > > > diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h > > index e6dc793d587d..c7e2b4421dc1 100644 > > --- a/include/linux/memcontrol.h > > +++ b/include/linux/memcontrol.h > > @@ -867,6 +867,12 @@ void mem_cgroup_print_oom_group(struct mem_cgroup > > *memcg); > > extern bool cgroup_memory_noswap; > > #endif > > > > +static inline void copy_page_memcg(struct page *dst, struct page *src) > > +{ > > + if (src->memcg_data) > > + dst->memcg_data = src->memcg_data; > > I would just drop the test. The struct page is a single cache line which > is dirty by the reference count so another store will unlikely be > noticeable even when NULL is stored here and you safe a conditional. > > > +} > > + > > struct mem_cgroup *lock_page_memcg(struct page *page); > > void __unlock_page_memcg(struct mem_cgroup *memcg); > > void unlock_page_memcg(struct page *page); > > @@ -1291,6 +1297,10 @@ mem_cgroup_print_oom_meminfo(struct mem_cgroup > > *memcg) > > { > > } > > > > +static inline void copy_page_memcg(struct page *dst, struct page *src) > > +{ > > +} > > + > > static inline struct mem_cgroup *lock_page_memcg(struct page *page) > > { > > return NULL; > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > > index 3e4b29ee2b1e..ee0a63dc1c9b 100644 > > --- a/mm/page_alloc.c > > +++ b/mm/page_alloc.c > > @@ -3307,8 +3307,10 @@ void split_page(struct page *page, unsigned int > > order) > > VM_BUG_ON_PAGE(PageCompound(page), page); > > VM_BUG_ON_PAGE(!page_count(page), page); > > > > - for (i = 1; i < (1 << order); i++) > > + for (i = 1; i < (1 << order); i++) { > > set_page_refcounted(page + i); > > + copy_page_memcg(page + i, page); > > + } > > split_page_owner(page, 1 << order); > > } > > EXPORT_SYMBOL_GPL(split_page); > > -- > > 2.25.0 > > > > -- > Michal Hocko > SUSE Labs
Re: Why do kprobes and uprobes singlestep?
On 03/01, Andy Lutomirski wrote: > > On Mon, Mar 1, 2021 at 8:51 AM Oleg Nesterov wrote: > > > > But I guess this has nothing to do with uprobes, they do not single-step > > in kernel mode, right? > > They single-step user code, though, and the code that makes this work > is quite ugly. Single-stepping on x86 is a mess. But this doesn't really differ from, say, gdb doing si ? OK, except uprobes have to hook DIE_DEBUG. Nevermind... > > > Uprobes seem to single-step user code for no discernable reason. > > > (They want to trap after executing an out of line instruction, AFAICT. > > > Surely INT3 or even CALL after the out-of-line insn would work as well > > > or better.) > > > > Uprobes use single-step from the very beginning, probably because this > > is the most simple and "standard" way to implement xol. > > > > And please note that CALL/JMP/etc emulation was added much later to fix the > > problems with non-canonical addresses, and this emulation it still > > incomplete. > > Is there something like a uprobe test suite? Afaik, no. > How maintained / Add Srikar who sent the initial implementation. I can only say that I am glad that ./scripts/get_maintainer.pl no longer mentions me ;) I did some changes (including emulation) but a) this was a long ago and b) only because I was forced^W asked to fix the numerous bugs in this code. > actively used is uprobe? I have no idea, sorry ;) Oleg.
[PATCH] Documentation: Add leading slash to some paths
Change multiple sys/xyz to /sys/xyz Signed-off-by: Mark O'Donovan --- Documentation/admin-guide/mm/numaperf.rst | 2 +- Documentation/fb/fbcon.rst| 4 ++-- Documentation/hid/intel-ish-hid.rst | 2 +- Documentation/leds/leds-lm3556.rst| 28 +++ 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/Documentation/admin-guide/mm/numaperf.rst b/Documentation/admin-guide/mm/numaperf.rst index c2f826409bf0..166697325947 100644 --- a/Documentation/admin-guide/mm/numaperf.rst +++ b/Documentation/admin-guide/mm/numaperf.rst @@ -151,7 +151,7 @@ Each cache level's directory provides its attributes. For example, the following shows a single cache level and the attributes available for software to query:: - # tree sys/devices/system/node/node0/memory_side_cache/ + # tree /sys/devices/system/node/node0/memory_side_cache/ /sys/devices/system/node/node0/memory_side_cache/ |-- index1 | |-- indexing diff --git a/Documentation/fb/fbcon.rst b/Documentation/fb/fbcon.rst index 57f66de2f7e1..212f7003cfba 100644 --- a/Documentation/fb/fbcon.rst +++ b/Documentation/fb/fbcon.rst @@ -207,9 +207,9 @@ Documentation/driver-api/console.rst. To summarize: Echo a value to the bind file that represents the framebuffer console driver. So assuming vtcon1 represents fbcon, then:: - echo 1 > sys/class/vtconsole/vtcon1/bind - attach framebuffer console to + echo 1 > /sys/class/vtconsole/vtcon1/bind - attach framebuffer console to console layer - echo 0 > sys/class/vtconsole/vtcon1/bind - detach framebuffer console from + echo 0 > /sys/class/vtconsole/vtcon1/bind - detach framebuffer console from console layer If fbcon is detached from the console layer, your boot console driver (which is diff --git a/Documentation/hid/intel-ish-hid.rst b/Documentation/hid/intel-ish-hid.rst index f6ce44ff611d..7a851252267a 100644 --- a/Documentation/hid/intel-ish-hid.rst +++ b/Documentation/hid/intel-ish-hid.rst @@ -345,7 +345,7 @@ Documentation/ABI/testing/sysfs-bus-iio for IIO ABIs to user space. To debug ISH, event tracing mechanism is used. To enable debug logs:: echo 1 > /sys/kernel/debug/tracing/events/intel_ish/enable - cat sys/kernel/debug/tracing/trace + cat /sys/kernel/debug/tracing/trace 3.8 ISH IIO sysfs Example on Lenovo thinkpad Yoga 260 - diff --git a/Documentation/leds/leds-lm3556.rst b/Documentation/leds/leds-lm3556.rst index 1ef17d7d800e..32e3983473ba 100644 --- a/Documentation/leds/leds-lm3556.rst +++ b/Documentation/leds/leds-lm3556.rst @@ -23,7 +23,7 @@ from 93.75 mA to 1500 mA.The Flash currents are adjusted via the CURRENT CONTROL REGISTER(0x09).Flash mode is activated by the ENABLE REGISTER(0x0A), or by pulling the STROBE pin HIGH. -LM3556 Flash can be controlled through sys/class/leds/flash/brightness file +LM3556 Flash can be controlled through /sys/class/leds/flash/brightness file * if STROBE pin is enabled, below example control brightness only, and ON / OFF will be controlled by STROBE pin. @@ -32,17 +32,17 @@ Flash Example: OFF:: - #echo 0 > sys/class/leds/flash/brightness + #echo 0 > /sys/class/leds/flash/brightness 93.75 mA:: - #echo 1 > sys/class/leds/flash/brightness + #echo 1 > /sys/class/leds/flash/brightness ... 1500 mA:: - #echo 16 > sys/class/leds/flash/brightness + #echo 16 > /sys/class/leds/flash/brightness Torch Mode ^^ @@ -51,7 +51,7 @@ In Torch Mode, the current source(LED) is programmed via the CURRENT CONTROL REGISTER(0x09).Torch Mode is activated by the ENABLE REGISTER(0x0A) or by the hardware TORCH input. -LM3556 torch can be controlled through sys/class/leds/torch/brightness file. +LM3556 torch can be controlled through /sys/class/leds/torch/brightness file. * if TORCH pin is enabled, below example control brightness only, and ON / OFF will be controlled by TORCH pin. @@ -59,22 +59,22 @@ Torch Example: OFF:: - #echo 0 > sys/class/leds/torch/brightness + #echo 0 > /sys/class/leds/torch/brightness 46.88 mA:: - #echo 1 > sys/class/leds/torch/brightness + #echo 1 > /sys/class/leds/torch/brightness ... 375 mA:: - #echo 8 > sys/class/leds/torch/brightness + #echo 8 > /sys/class/leds/torch/brightness Indicator Mode ^^ -Indicator pattern can be set through sys/class/leds/indicator/pattern file, +Indicator pattern can be set through /sys/class/leds/indicator/pattern file, and 4 patterns are pre-defined in indicator_pattern array. According to N-lank, Pulse time and N Period values, different pattern wiill @@ -87,13 +87,13 @@ Indicator pattern example: pattern 0:: - #echo 0 > sys/class/leds/indicator/pattern + #echo 0 > /sys/class/leds/indicator/pattern ... pattern 3::
Re: Why do kprobes and uprobes singlestep?
forgot to add Srikar, sorry for resend... On 03/01, Andy Lutomirski wrote: > > On Mon, Mar 1, 2021 at 8:51 AM Oleg Nesterov wrote: > > > > But I guess this has nothing to do with uprobes, they do not single-step > > in kernel mode, right? > > They single-step user code, though, and the code that makes this work > is quite ugly. Single-stepping on x86 is a mess. But this doesn't really differ from, say, gdb doing si ? OK, except uprobes have to hook DIE_DEBUG. Nevermind... > > > Uprobes seem to single-step user code for no discernable reason. > > > (They want to trap after executing an out of line instruction, AFAICT. > > > Surely INT3 or even CALL after the out-of-line insn would work as well > > > or better.) > > > > Uprobes use single-step from the very beginning, probably because this > > is the most simple and "standard" way to implement xol. > > > > And please note that CALL/JMP/etc emulation was added much later to fix the > > problems with non-canonical addresses, and this emulation it still > > incomplete. > > Is there something like a uprobe test suite? Afaik, no. > How maintained / Add Srikar who sent the initial implementation. I can only say that I am glad that ./scripts/get_maintainer.pl no longer mentions me ;) I did some changes (including emulation) but a) this was a long ago and b) only because I was forced^W asked to fix the numerous bugs in this code. > actively used is uprobe? I have no idea, sorry ;) Oleg.
Re: hppa64-linux-ld: kernel/sched/core.o(.init.text+0x90): cannot reach printk
* Helge Deller : > On 3/2/21 7:07 PM, Nick Desaulniers wrote: > > + Arnd > > > > On Tue, Mar 2, 2021 at 10:03 AM Helge Deller wrote: > > > > > > On 3/2/21 6:29 PM, Nick Desaulniers wrote: > > > > + pa-risc folks > > > > > > Thanks for looking into this, Nick! > > > > > > > On Tue, Mar 2, 2021 at 2:59 AM kernel test robot wrote: > > > > > > > > > > tree: > > > > > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git > > > > > master > > > > > head: 7a7fd0de4a9804299793e564a555a49c1fc924cb > > > > > commit: eff8728fe69880d3f7983bec3fb6cea4c306261f vmlinux.lds.h: Add > > > > > PGO and AutoFDO input sections > > > > > > > > This commit added sections explicitly to the kernel's linker script. > > > > > > Yes, but even when reverting this patch it does not prevent > > > the linking problems. > > > > > > > > > > > date: 6 months ago > > > > > config: parisc-randconfig-s031-20210228 (attached as .config) > > > > > > > > ^ randconfig (always find something curious) > > > > > > Yes :-) > > > > > > > > > > > compiler: hppa64-linux-gcc (GCC) 9.3.0 > > > > > reproduce: > > > > > wget > > > > > https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross > > > > > -O ~/bin/make.cross > > > > > chmod +x ~/bin/make.cross > > > > > # apt-get install sparse > > > > > # sparse version: v0.6.3-241-geaceeafa-dirty > > > > > # > > > > > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=eff8728fe69880d3f7983bec3fb6cea4c306261f > > > > > git remote add linus > > > > > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git > > > > > git fetch --no-tags linus master > > > > > git checkout eff8728fe69880d3f7983bec3fb6cea4c306261f > > > > > # save the attached .config to linux build tree > > > > > COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 > > > > > make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=parisc > > > > > > > > > > If you fix the issue, kindly add following tag as appropriate > > > > > Reported-by: kernel test robot > > > > > > > > > > All errors (new ones prefixed by >>): > > > > > > > > > > hppa64-linux-ld: init/main.o(.init.text+0x294): cannot reach > > > > > printk > > > > > init/main.o: in function `do_early_param': > > > > > (.init.text+0x294): relocation truncated to fit: > > > > > R_PARISC_PCREL22F against symbol `printk' defined in .text.unlikely > > > > > section in kernel/printk/printk.o > > > > > > > > ^ so we can't encode a jump to printk from do_early_param. > > > > > > Right. > > > > > > > If the linker is warning that printk is in the .text.unlikely > > > > section, I'm curious why printk is marked cold? > > > > > > printk is always marked cold, see include/linux/printk.h: > > > asmlinkage __printf(1, 2) __cold > > > int printk(const char *fmt, ...); > > > > > > > Likely the randconfig produces a large TEXT_MAIN; > > > > > > Yes. > > > > > > > I'm guessing that .init.text is on one side of TEXT_MAIN, and > > > > .text.unlikely is on the other. Though there are many different > > > > instances below. > > > Yes. But even the large TEXT_MAIN by itself can become a problem. > > > > > > > I'm more familiar with ARM; it's common for the linker to insert > > > > trampolines/thunks to bridge jumps too large to encode in a given > > > > instruction. I don't know if BFD has arch agnostic machinery for > > > > that, but might be seeing if there's anything reuseable there. > > > > > > Dave mentioned in another mail, that long branch stub support is > > > still missing in the 64-bit parisc linker. > > > > > > My question still remains: > > > Is there any possibility to detect that we build/configure a > > > 0-day kernel? If so, auto-enabling CONFIG_MLONGCALLS kernel option > > > would solve it (temporarily). > > > > Arnd, is this kind of case what CONFIG_COMPILE_TEST is usually used for? > > Yes, I think that's the right knob! > CONFIG_COMPILE_TEST is enabled on all parisc configs for which 0-day > reported issues. > I've wired it up in Kconfig and it now works around the issue. I've committed the patch below to the parisc for-next tree, which allows to monitor if this fixes the linkage problems... Helge From: Helge Deller Date: Tue, 2 Mar 2021 21:07:07 +0100 Subject: [PATCH] parisc: Enable -mlong-calls gcc option with CONFIG_COMPILE_TEST The kernel test robot reported multiple linkage problems like this: hppa64-linux-ld: init/main.o(.init.text+0x56c): cannot reach printk init/main.o: in function `unknown_bootoption': (.init.text+0x56c): relocation truncated to fit: R_PARISC_PCREL22F against symbol `printk' defined in .text.unlikely section in kernel/printk/printk.o There are two ways to solve it: a) Enable the -mlong-call compiler option (CONFIG_MLONGCALLS), b) Add long branch stub support in 64-bit linker. While b) is the long-term solution, this patch works around
Re: Why do kprobes and uprobes singlestep?
On 03/02, Masami Hiramatsu wrote: > > > Not sure I understand you correctly, I know almost nothing about low-level > > x86 magic. > > x86 has normal interrupt and NMI. When an NMI occurs the CPU masks NMI > (the mask itself is hidden status) and IRET releases the mask. The problem > is that if an INT3 is hit in the NMI handler and does a single-stepping, > it has to use IRET for atomically setting TF and return. Ah, thanks a lot, Oleg.
Re: [PATCH v3 6/7] drm: sun4i: dsi: Use drm_panel_bridge, connector API
On Tue, Mar 2, 2021 at 10:05 PM Maxime Ripard wrote: > > On Fri, Feb 26, 2021 at 10:40:24PM +0530, Jagan Teki wrote: > > On Fri, Feb 26, 2021 at 10:27 PM Maxime Ripard wrote: > > > > > > Hi, > > > > > > On Mon, Feb 15, 2021 at 01:11:01AM +0530, Jagan Teki wrote: > > > > Use drm_panel_bridge to replace manual panel handling code. > > > > > > > > This simplifies the driver to allows all components in the > > > > display pipeline to be treated as bridges, paving the way > > > > to generic connector handling. > > > > > > > > Use drm_bridge_connector_init to create a connector for display > > > > pipelines that use drm_bridge. > > > > > > > > This allows splitting connector operations across multiple bridges > > > > when necessary, instead of having the last bridge in the chain > > > > creating the connector and handling all connector operations > > > > internally. > > > > > > > > Signed-off-by: Jagan Teki > > > > > > Most of the code removed in that patch was actually introduced earlier > > > which feels a bit weird. Is there a reason we can't do that one first, > > > and then introduce the bridge support? > > > > This patch adds new bridge API's which requires the driver has to > > support the bridge first. > > I'm not sure what you're saying, you can definitely have a bridge > without support for a downstream bridge. I understand your point. what I'm saying here is, This patch introduces two new bridge API's devm_drm_panel_bridge_add drm_bridge_connector_init In order to add these API's the driver has to support the bridge first. All the patches before this one support bridge and this patch introduce new APIs, ie the reason we have code removed in this patch which has been added before. Okay. I think I will send the next version series till bridge conversion. Improvement patches like this can take care of later versions and even it depends on Patch v3 5/7 which indeed require a separate discussion. This way it makes less confusion. Hope it's fine for you? Jagan.
Re: hppa64-linux-ld: kernel/sched/core.o(.init.text+0x90): cannot reach printk
On Tue, Mar 2, 2021 at 9:28 PM Helge Deller wrote: > * Helge Deller : > > On 3/2/21 7:07 PM, Nick Desaulniers wrote: > > > + Arnd > > > > > > On Tue, Mar 2, 2021 at 10:03 AM Helge Deller wrote: > > > > > > > > > From: Helge Deller > Date: Tue, 2 Mar 2021 21:07:07 +0100 > Subject: [PATCH] parisc: Enable -mlong-calls gcc option with > CONFIG_COMPILE_TEST > > The kernel test robot reported multiple linkage problems like this: > > hppa64-linux-ld: init/main.o(.init.text+0x56c): cannot reach printk > init/main.o: in function `unknown_bootoption': > (.init.text+0x56c): relocation truncated to fit: R_PARISC_PCREL22F against > symbol `printk' defined in .text.unlikely section in > kernel/printk/printk.o > > There are two ways to solve it: > a) Enable the -mlong-call compiler option (CONFIG_MLONGCALLS), > b) Add long branch stub support in 64-bit linker. > > While b) is the long-term solution, this patch works around the issue by > automatically enabling the CONFIG_MLONGCALLS option when > CONFIG_COMPILE_TEST is set, which indicates that a non-production kernel > (e.g. 0-day kernel) is built. > > Signed-off-by: Helge Deller > Reported-by: kernel test robot > Fixes: 00e35f2b0e8a ("parisc: Enable -mlong-calls gcc option by default when > !CONFIG_MODULES") > Cc: sta...@vger.kernel.org # v5.6+ > > diff --git a/arch/parisc/Kconfig b/arch/parisc/Kconfig > index 4e53ac46e857..afc3b8d03572 100644 > --- a/arch/parisc/Kconfig > +++ b/arch/parisc/Kconfig > @@ -203,9 +203,12 @@ config PREFETCH > def_bool y > depends on PA8X00 || PA7200 > > +config PARISC_HUGE_KERNEL > + def_bool y if !MODULES || UBSAN || FTRACE || COMPILE_TEST > + > config MLONGCALLS > - def_bool y if !MODULES || UBSAN || FTRACE > - bool "Enable the -mlong-calls compiler option for big kernels" if > MODULES && !UBSAN && !FTRACE > + def_bool y if PARISC_HUGE_KERNEL > + bool "Enable the -mlong-calls compiler option for big kernels" if > !PARISC_HUGE_KERNEL > depends on PA8X00 > help > If you configure the kernel to include many drivers built-in instead Looks good to me, we should probably do something similar on arm with CONFIG_{ARM,ARM64}_MODULE_PLTS, though that only affects loadable modules, as the linker would insert its own trampolines during the final link when branch relocations are out of range. Arnd