Re: [PATCH] LoongArch: make the users of larch_insn_gen_break() constant

2024-06-30 Thread Tiezhu Yang

On 06/29/2024 11:03 PM, Oleg Nesterov wrote:

LoongArch defines UPROBE_SWBP_INSN as a function call and this breaks
arch_uprobe_trampoline() which uses it to initialize a static variable.

Add the new "__builtin_constant_p" helper, __emit_break(), and redefine
the current users of larch_insn_gen_break() to use it.

The patch adds check_emit_break() into kprobes.c and uprobes.c to test
this change. They can be removed if LoongArch boots at least once, but
otoh these 2 __init functions will be discarded by free_initmem().

Fixes: ff474a78cef5 ("uprobe: Add uretprobe syscall to speed up return probe")
Reported-by: Nathan Chancellor 
Closes: https://lore.kernel.org/all/20240614174822.GA1185149@thelio-3990X/
Suggested-by: Andrii Nakryiko 
Signed-off-by: Oleg Nesterov 


Tested on LoongArch machine with Loongson-3A5000 and Loongson-3A6000
CPU, based on 6.10-rc3,

KPROBE_BP_INSN == larch_insn_gen_break(BRK_KPROBE_BP)
KPROBE_SSTEPBP_INSN == larch_insn_gen_break(BRK_KPROBE_SSTEPBP)
UPROBE_SWBP_INSN  == larch_insn_gen_break(BRK_UPROBE_BP)
UPROBE_XOLBP_INSN == larch_insn_gen_break(BRK_UPROBE_XOLBP)

The two functions check_emit_break() can be removed in
arch/loongarch/kernel/kprobes.c and arch/loongarch/kernel/uprobes.c

Tested-by: Tiezhu Yang 

Thanks,
Tiezhu




[PATCH] vhost-vdpa: switch to use vmf_insert_pfn() in the fault handler

2024-06-30 Thread Jason Wang
remap_pfn_page() should not be called in the fault handler as it may
change the vma->flags which may trigger lockdep warning since the vma
write lock is not held. Actually there's no need to modify the
vma->flags as it has been set in the mmap(). So this patch switches to
use vmf_insert_pfn() instead.

Reported-by: Dragos Tatulea 
Tested-by: Dragos Tatulea 
Fixes: ddd89d0a059d ("vhost_vdpa: support doorbell mapping via mmap")
Cc: sta...@vger.kernel.org
Signed-off-by: Jason Wang 
---
 drivers/vhost/vdpa.c | 8 +---
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c
index 63a53680a85c..6b9c12acf438 100644
--- a/drivers/vhost/vdpa.c
+++ b/drivers/vhost/vdpa.c
@@ -1483,13 +1483,7 @@ static vm_fault_t vhost_vdpa_fault(struct vm_fault *vmf)
 
notify = ops->get_vq_notification(vdpa, index);
 
-   vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
-   if (remap_pfn_range(vma, vmf->address & PAGE_MASK,
-   PFN_DOWN(notify.addr), PAGE_SIZE,
-   vma->vm_page_prot))
-   return VM_FAULT_SIGBUS;
-
-   return VM_FAULT_NOPAGE;
+   return vmf_insert_pfn(vma, vmf->address & PAGE_MASK, 
PFN_DOWN(notify.addr));
 }
 
 static const struct vm_operations_struct vhost_vdpa_vm_ops = {
-- 
2.31.1




[PATCH] uapi: change TRACE_MMAP_IOCTL_GET_READER to avoid collision with TCGETS

2024-06-30 Thread Dmitry V. Levin
The number that was initially chosen for TRACE_MMAP_IOCTL_GET_READER,
unfortunately, collides with TCGETS on most of architectures.

For example, this is how strace output would look like when
support for this value of TRACE_MMAP_IOCTL_GET_READER is added:

$ strace -e ioctl stty
ioctl(0, TCGETS or TRACE_MMAP_IOCTL_GET_READER, {c_iflag=ICRNL|IXON, 
c_oflag=NL0|CR0|TAB0|BS0|VT0|FF0|OPOST|ONLCR,
+c_cflag=B38400|CS8|CREAD, 
c_lflag=ISIG|ICANON|ECHO|ECHOE|ECHOK|IEXTEN|ECHOCTL|ECHOKE, ...}) = 0

Even though ioctl numbers are inherently not unique, TCGETS
is a very traditional one, so let's change the value of
TRACE_MMAP_IOCTL_GET_READER a bit to avoid this collision.

Given that _IO('T', 0x1) is _IOC(_IOC_NONE, 'T', 0x1, 0),
something like _IOC(_IOC_NONE, 'T', 0x1, 0x1) should be OK.

Fixes: cf9f0f7c4c5bb ("tracing: Allow user-space mapping of the ring-buffer")
Signed-off-by: Dmitry V. Levin 
---
 include/uapi/linux/trace_mmap.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/uapi/linux/trace_mmap.h b/include/uapi/linux/trace_mmap.h
index bd1066754220..cb858f1b8367 100644
--- a/include/uapi/linux/trace_mmap.h
+++ b/include/uapi/linux/trace_mmap.h
@@ -43,6 +43,6 @@ struct trace_buffer_meta {
__u64   Reserved2;
 };
 
-#define TRACE_MMAP_IOCTL_GET_READER_IO('T', 0x1)
+#define TRACE_MMAP_IOCTL_GET_READER_IOC(_IOC_NONE, 'T', 0x1, 0x1)
 
 #endif /* _TRACE_MMAP_H_ */
-- 
ldv



[PATCH v3 2/2] ARM: dts: qcom-msm8226-samsung-ms013g: Add initial device tree

2024-06-30 Thread Raymond Hackley
Samsung Galaxy Grand 2 is a phone based on MSM8226. It's similar to the
other Samsung devices based on MSM8226 with only a few minor differences.

The device trees contain initial support with:
 - GPIO keys
 - Regulator haptic
 - SDHCI (internal and external storage)
 - UART (on USB connector via the TI TSU6721 MUIC)
 - Regulators
 - Touchscreen
 - Accelerometer

Signed-off-by: Raymond Hackley 
Reviewed-by: Luca Weiss 
Reviewed-by: Konrad Dybcio 
---
 arch/arm/boot/dts/qcom/Makefile   |   1 +
 .../dts/qcom/qcom-msm8226-samsung-ms013g.dts  | 386 ++
 2 files changed, 387 insertions(+)
 create mode 100644 arch/arm/boot/dts/qcom/qcom-msm8226-samsung-ms013g.dts

diff --git a/arch/arm/boot/dts/qcom/Makefile b/arch/arm/boot/dts/qcom/Makefile
index ccd4ce6353df..f06c6d425e91 100644
--- a/arch/arm/boot/dts/qcom/Makefile
+++ b/arch/arm/boot/dts/qcom/Makefile
@@ -28,6 +28,7 @@ dtb-$(CONFIG_ARCH_QCOM) += \
qcom-msm8226-microsoft-dempsey.dtb \
qcom-msm8226-microsoft-makepeace.dtb \
qcom-msm8226-microsoft-moneypenny.dtb \
+   qcom-msm8226-samsung-ms013g.dtb \
qcom-msm8226-samsung-s3ve3g.dtb \
qcom-msm8660-surf.dtb \
qcom-msm8916-samsung-e5.dtb \
diff --git a/arch/arm/boot/dts/qcom/qcom-msm8226-samsung-ms013g.dts 
b/arch/arm/boot/dts/qcom/qcom-msm8226-samsung-ms013g.dts
new file mode 100644
index ..2ecc5983d365
--- /dev/null
+++ b/arch/arm/boot/dts/qcom/qcom-msm8226-samsung-ms013g.dts
@@ -0,0 +1,386 @@
+// SPDX-License-Identifier: BSD-3-Clause
+
+/dts-v1/;
+
+#include "qcom-msm8226.dtsi"
+#include "pm8226.dtsi"
+
+/delete-node/ &smem_region;
+
+/ {
+   model = "Samsung Galaxy Grand 2";
+   compatible = "samsung,ms013g", "qcom,msm8226";
+   chassis-type = "handset";
+
+   aliases {
+   mmc0 = &sdhc_1; /* SDC1 eMMC slot */
+   mmc1 = &sdhc_2; /* SDC2 SD card slot */
+   serial0 = &blsp1_uart3;
+   };
+
+   chosen {
+   stdout-path = "serial0:115200n8";
+   };
+
+   gpio-hall-sensor {
+   compatible = "gpio-keys";
+
+   pinctrl-0 = <&gpio_hall_sensor_default>;
+   pinctrl-names = "default";
+
+   label = "GPIO Hall Effect Sensor";
+
+   event-hall-sensor {
+   label = "Hall Effect Sensor";
+   gpios = <&tlmm 50 GPIO_ACTIVE_LOW>;
+   linux,input-type = ;
+   linux,code = ;
+   linux,can-disable;
+   };
+   };
+
+   gpio-keys {
+   compatible = "gpio-keys";
+
+   pinctrl-0 = <&gpio_keys_default>;
+   pinctrl-names = "default";
+
+   label = "GPIO Buttons";
+
+   button-volume-up {
+   label = "Volume Up";
+   gpios = <&tlmm 106 GPIO_ACTIVE_LOW>;
+   linux,code = ;
+   };
+
+   button-volume-down {
+   label = "Volume Down";
+   gpios = <&tlmm 107 GPIO_ACTIVE_LOW>;
+   linux,code = ;
+   };
+
+   button-home {
+   label = "Home Key";
+   gpios = <&tlmm 108 GPIO_ACTIVE_LOW>;
+   linux,code = ;
+   };
+   };
+
+   reg_motor_vdd: regulator-motor-vdd {
+   compatible = "regulator-fixed";
+   regulator-name = "motor_vdd";
+   regulator-min-microvolt = <330>;
+   regulator-max-microvolt = <330>;
+
+   gpio = <&tlmm 111 GPIO_ACTIVE_HIGH>;
+   enable-active-high;
+
+   pinctrl-0 = <&motor_en_default>;
+   pinctrl-names = "default";
+   };
+
+   reg_vdd_tsp_a: regulator-vdd-tsp-a {
+   compatible = "regulator-fixed";
+   regulator-name = "tsp_3p3v";
+   regulator-min-microvolt = <330>;
+   regulator-max-microvolt = <330>;
+
+   gpio = <&tlmm 31 GPIO_ACTIVE_HIGH>;
+   enable-active-high;
+
+   pinctrl-0 = <&tsp_en_default>;
+   pinctrl-names = "default";
+   };
+
+   reserved-memory {
+   smem_region: smem@fa0 {
+   reg = <0x0fa0 0x10>;
+   no-map;
+   };
+   };
+
+   vibrator {
+   compatible = "regulator-haptic";
+   haptic-supply = <®_motor_vdd>;
+   min-microvolt = <330>;
+   max-microvolt = <330>;
+   };
+};
+
+&blsp1_i2c2 {
+   status = "okay";
+
+   accelerometer@18 {
+   compatible = "bosch,bma255";
+   reg = <0x18>;
+   interrupts-extended = <&tlmm 64 IRQ_TYPE_EDGE_RISING>;
+
+   vdd-supply = <&pm8226_l19>;
+   vddio-supply = <&pm8226_lvs1>;
+
+

[PATCH v3 1/2] dt-bindings: arm: qcom: Document samsung,ms013g

2024-06-30 Thread Raymond Hackley
Document samsung,ms013g for Galaxy Grand 2.

Signed-off-by: Raymond Hackley 
---
 Documentation/devicetree/bindings/arm/qcom.yaml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/arm/qcom.yaml 
b/Documentation/devicetree/bindings/arm/qcom.yaml
index ec1c10a12470..7990e7e27542 100644
--- a/Documentation/devicetree/bindings/arm/qcom.yaml
+++ b/Documentation/devicetree/bindings/arm/qcom.yaml
@@ -141,6 +141,7 @@ properties:
   - microsoft,makepeace
   - microsoft,moneypenny
   - motorola,falcon
+  - samsung,ms013g
   - samsung,s3ve3g
   - const: qcom,msm8226
 
-- 
2.39.2





[PATCH v3 0/2] ARM: dts: qcom-msm8226-samsung-ms013g: Add initial device tree

2024-06-30 Thread Raymond Hackley
Samsung Galaxy Grand 2 is a phone based on MSM8226. It's similar to the
other Samsung devices based on MSM8226 with only a few minor differences.

The device trees contain initial support with:
 - GPIO keys
 - Regulator haptic
 - SDHCI (internal and external storage)
 - UART (on USB connector via the TI TSU6721 MUIC)
 - Regulators
 - Touchscreen
 - Accelerometer

---
v2: Adjust l3, l15, l22 and l27 regulator voltages. Sort nodes.
Set regulator-allow-set-load for vqmmc supplies.
v3: Rename node haptic to vibrator.




Re: [PATCH v23 3/5] tracing: Allow user-space mapping of the ring-buffer

2024-06-30 Thread Steven Rostedt
On Sun, 30 Jun 2024 13:53:23 +0300
"Dmitry V. Levin"  wrote:

> On Fri, May 10, 2024 at 03:04:32PM +0100, Vincent Donnefort wrote:
> [...]
> > diff --git a/include/uapi/linux/trace_mmap.h 
> > b/include/uapi/linux/trace_mmap.h
> > index b682e9925539..bd1066754220 100644
> > --- a/include/uapi/linux/trace_mmap.h
> > +++ b/include/uapi/linux/trace_mmap.h
> > @@ -43,4 +43,6 @@ struct trace_buffer_meta {
> > __u64   Reserved2;
> >  };
> >  
> > +#define TRACE_MMAP_IOCTL_GET_READER_IO('T', 0x1)
> > +  
> 
> I'm sorry but among all the numbers this one was probably the least
> fortunate choice because it collides with TCGETS on most of architectures.

Hmm, that is unfortunate.

> 
> For example, this is how strace output would look like when
> TRACE_MMAP_IOCTL_GET_READER support is added:
> 
> $ strace -e ioctl stty
> ioctl(0, TCGETS or TRACE_MMAP_IOCTL_GET_READER, {c_iflag=ICRNL|IXON, 
> c_oflag=NL0|CR0|TAB0|BS0|VT0|FF0|OPOST|ONLCR, c_cflag=B38400|CS8|CREAD, 
> c_lflag=ISIG|ICANON|ECHO|ECHOE|ECHOK|IEXTEN|ECHOCTL|ECHOKE, ...}) = 0
> 
> Even though ioctl numbers are inherently not unique, TCGETS is
> a very traditional one, so it would be great if you could change
> TRACE_MMAP_IOCTL_GET_READER to avoid this collision.
> 
> Given that _IO('T', 0x1) is _IOC(_IOC_NONE, 'T', 0x1, 0),
> something like _IOC(_IOC_NONE, 'T', 0x1, 0x1) should be OK.

Well, it may not be too late to update this as it hasn't been
officially released in 6.10 yet. It's still only in the -rc and the
library doesn't rely on this yet (I've been holding off until 6.10 was
officially released before releasing the library that uses it).

I can send a patch this week to update it. Or feel free to send a patch
yourself.

Thanks,

-- Steve



Re: [PATCH v23 3/5] tracing: Allow user-space mapping of the ring-buffer

2024-06-30 Thread Dmitry V. Levin
On Fri, May 10, 2024 at 03:04:32PM +0100, Vincent Donnefort wrote:
[...]
> diff --git a/include/uapi/linux/trace_mmap.h b/include/uapi/linux/trace_mmap.h
> index b682e9925539..bd1066754220 100644
> --- a/include/uapi/linux/trace_mmap.h
> +++ b/include/uapi/linux/trace_mmap.h
> @@ -43,4 +43,6 @@ struct trace_buffer_meta {
>   __u64   Reserved2;
>  };
>  
> +#define TRACE_MMAP_IOCTL_GET_READER  _IO('T', 0x1)
> +

I'm sorry but among all the numbers this one was probably the least
fortunate choice because it collides with TCGETS on most of architectures.

For example, this is how strace output would look like when
TRACE_MMAP_IOCTL_GET_READER support is added:

$ strace -e ioctl stty
ioctl(0, TCGETS or TRACE_MMAP_IOCTL_GET_READER, {c_iflag=ICRNL|IXON, 
c_oflag=NL0|CR0|TAB0|BS0|VT0|FF0|OPOST|ONLCR, c_cflag=B38400|CS8|CREAD, 
c_lflag=ISIG|ICANON|ECHO|ECHOE|ECHOK|IEXTEN|ECHOCTL|ECHOKE, ...}) = 0

Even though ioctl numbers are inherently not unique, TCGETS is
a very traditional one, so it would be great if you could change
TRACE_MMAP_IOCTL_GET_READER to avoid this collision.

Given that _IO('T', 0x1) is _IOC(_IOC_NONE, 'T', 0x1, 0),
something like _IOC(_IOC_NONE, 'T', 0x1, 0x1) should be OK.


-- 
ldv