Skip to contentSkip to conversation

RISC-V: recognize S/U mode bits in print_isa

PATCH Superseded Patrick Stählin 2 participants 4 messages Nov 9, 2018 – Nov 16, 2018 RISC-V

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 RISC-V: recognize S/U mode bits in print_isa

Removes the warning about an unsupported ISA when reading /proc/cpuinfo on QEMU.

---
 arch/riscv/kernel/cpu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/riscv/kernel/cpu.c +1 -1
index 3a5a2ee31547..4029c7e6872b 100644
@@ -64,7 +64,7 @@ int riscv_of_processor_hartid(struct device_node *node)
 
 static void print_isa(struct seq_file *f, const char *orig_isa)
 {
-	static const char *ext = "mafdc";
+	static const char *ext = "mafdcsu";
 	const char *isa = orig_isa;
 	const char *e;
 
Signature · 1 line
2.17.1
#1 lore raw
Quoted 13 lines · me at packi.ch

Removes the warning about an unsupported ISA when reading /proc/cpuinfo on QEMU.

---
 arch/riscv/kernel/cpu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/riscv/kernel/cpu.c +0 -0
index 3a5a2ee31547..4029c7e6872b 100644

arch/riscv/kernel/cpu.c int riscv_of_processor_hartid(struct device_node *node) · line 69

Quoted 7 lines
arch/riscv/kernel/cpu.c +1 -1
@@ -64,7 +64,7 @@ int riscv_of_processor_hartid(struct device_node *node)
 
 static void print_isa(struct seq_file *f, const char *orig_isa)
 {
-	static const char *ext = "mafdc";
+	static const char *ext = "mafdcsu";
 	const char *isa = orig_isa;
 	const char *e;

This is a bit pedantic, but the "S" extension should really be hidden from userspace.

#2 lore raw

PATCH v2 1/1 RISC-V: recognize S/U mode bits in print_isa

Removes the warning about an unsupported ISA when reading /proc/cpuinfo on QEMU. The "S" extension is not being returned as it is not accessible from userspace.

---
 arch/riscv/kernel/cpu.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
arch/riscv/kernel/cpu.c +6 -3
index 3a5a2ee31547..b4a7d4427fbb 100644
@@ -64,7 +64,7 @@ int riscv_of_processor_hartid(struct device_node *node)
 
 static void print_isa(struct seq_file *f, const char *orig_isa)
 {
-	static const char *ext = "mafdc";
+	static const char *ext = "mafdcsu";
 	const char *isa = orig_isa;
 	const char *e;
 
@@ -88,11 +88,14 @@ static void print_isa(struct seq_file *f, const char *orig_isa)
 	/*
 	 * Check the rest of the ISA string for valid extensions, printing those
 	 * we find.  RISC-V ISA strings define an order, so we only print the
-	 * extension bits when they're in order.
+	 * extension bits when they're in order. Hide the supervisor (S)
+	 * extension from userspace as it's not accessible from there.
 	 */
 	for (e = ext; *e != '\0'; ++e) {
 		if (isa[0] == e[0]) {
-			seq_write(f, isa, 1);
+			if (isa[0] != 's')
+				seq_write(f, isa, 1);
+
 			isa++;
 		}
 	}
Signature · 1 line
2.17.1
#3 lore raw
Quoted 29 lines · me at packi.ch

Removes the warning about an unsupported ISA when reading /proc/cpuinfo on QEMU. The "S" extension is not being returned as it is not accessible from userspace.

---
 arch/riscv/kernel/cpu.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
arch/riscv/kernel/cpu.c +3 -2
index 3a5a2ee31547..b4a7d4427fbb 100644
@@ -64,7 +64,7 @@ int riscv_of_processor_hartid(struct device_node *node)
 
 static void print_isa(struct seq_file *f, const char *orig_isa)
 {
-	static const char *ext = "mafdc";
+	static const char *ext = "mafdcsu";
 	const char *isa = orig_isa;
 	const char *e;
 
@@ -88,11 +88,14 @@ static void print_isa(struct seq_file *f, const char *orig_isa)
 	/*
 	 * Check the rest of the ISA string for valid extensions, printing those
 	 * we find.  RISC-V ISA strings define an order, so we only print the
-	 * extension bits when they're in order.
+	 * extension bits when they're in order. Hide the supervisor (S)
+	 * extension from userspace as it's not accessible from there.

arch/riscv/kernel/cpu.c static void print_isa(struct seq_file *f, const char *orig_isa) · line 101

Quoted 10 lines
arch/riscv/kernel/cpu.c +3 -1
 	 */
 	for (e = ext; *e != '\0'; ++e) {
 		if (isa[0] == e[0]) {
-			seq_write(f, isa, 1);
+			if (isa[0] != 's')
+				seq_write(f, isa, 1);
+
 			isa++;
 		}
 	}

This looks good to me. I'll target it for the RCs, as it's fairly small and that warning fires too often.

Thanks!