forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
riscv: Extend cpufeature.c to detect vendor extensions
Instead of grouping all vendor extensions into the same riscv_isa_ext that standard instructions use, create a struct "riscv_isa_vendor_ext_data_list" that allows each vendor to maintain their vendor extensions independently of the standard extensions. xandespmu is currently the only vendor extension so that is the only extension that is affected by this change. An additional benefit of this is that the extensions of each vendor can be conditionally enabled. A config RISCV_ISA_VENDOR_EXT_ANDES has been added to allow for that. Signed-off-by: Charlie Jenkins <[email protected]> Reviewed-by: Conor Dooley <[email protected]> Reviewed-by: Andy Chiu <[email protected]> Tested-by: Yu Chien Peter Lin <[email protected]> Reviewed-by: Yu Chien Peter Lin <[email protected]> Link: https://lore.kernel.org/r/20240719-support_vendor_extensions-v3-1-0af7587bbec0@rivosinc.com Signed-off-by: Palmer Dabbelt <[email protected]>
- Loading branch information
1 parent
5ee121a
commit 23c996f
Showing
15 changed files
with
324 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
menu "Vendor extensions" | ||
|
||
config RISCV_ISA_VENDOR_EXT | ||
bool | ||
|
||
menu "Andes" | ||
config RISCV_ISA_VENDOR_EXT_ANDES | ||
bool "Andes vendor extension support" | ||
select RISCV_ISA_VENDOR_EXT | ||
default y | ||
help | ||
Say N here if you want to disable all Andes vendor extension | ||
support. This will cause any Andes vendor extensions that are | ||
requested by hardware probing to be ignored. | ||
|
||
If you don't know what to do here, say Y. | ||
endmenu | ||
|
||
endmenu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* SPDX-License-Identifier: GPL-2.0-only */ | ||
/* | ||
* Copyright 2024 Rivos, Inc | ||
*/ | ||
|
||
#ifndef _ASM_VENDOR_EXTENSIONS_H | ||
#define _ASM_VENDOR_EXTENSIONS_H | ||
|
||
#include <asm/cpufeature.h> | ||
|
||
#include <linux/array_size.h> | ||
#include <linux/types.h> | ||
|
||
/* | ||
* The extension keys of each vendor must be strictly less than this value. | ||
*/ | ||
#define RISCV_ISA_VENDOR_EXT_MAX 32 | ||
|
||
struct riscv_isavendorinfo { | ||
DECLARE_BITMAP(isa, RISCV_ISA_VENDOR_EXT_MAX); | ||
}; | ||
|
||
struct riscv_isa_vendor_ext_data_list { | ||
bool is_initialized; | ||
const size_t ext_data_count; | ||
const struct riscv_isa_ext_data *ext_data; | ||
struct riscv_isavendorinfo per_hart_isa_bitmap[NR_CPUS]; | ||
struct riscv_isavendorinfo all_harts_isa_bitmap; | ||
}; | ||
|
||
extern struct riscv_isa_vendor_ext_data_list *riscv_isa_vendor_ext_list[]; | ||
|
||
extern const size_t riscv_isa_vendor_ext_list_size; | ||
|
||
/* | ||
* The alternatives need some way of distinguishing between vendor extensions | ||
* and errata. Incrementing all of the vendor extension keys so they are at | ||
* least 0x8000 accomplishes that. | ||
*/ | ||
#define RISCV_VENDOR_EXT_ALTERNATIVES_BASE 0x8000 | ||
|
||
#define VENDOR_EXT_ALL_CPUS -1 | ||
|
||
bool __riscv_isa_vendor_extension_available(int cpu, unsigned long vendor, unsigned int bit); | ||
#define riscv_isa_vendor_extension_available(vendor, ext) \ | ||
__riscv_isa_vendor_extension_available(VENDOR_EXT_ALL_CPUS, vendor, \ | ||
RISCV_ISA_VENDOR_EXT_##ext) | ||
|
||
#endif /* _ASM_VENDOR_EXTENSIONS_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* SPDX-License-Identifier: GPL-2.0 */ | ||
#ifndef _ASM_RISCV_VENDOR_EXTENSIONS_ANDES_H | ||
#define _ASM_RISCV_VENDOR_EXTENSIONS_ANDES_H | ||
|
||
#include <asm/vendor_extensions.h> | ||
|
||
#include <linux/types.h> | ||
|
||
#define RISCV_ISA_VENDOR_EXT_XANDESPMU 0 | ||
|
||
/* | ||
* Extension keys should be strictly less than max. | ||
* It is safe to increment this when necessary. | ||
*/ | ||
#define RISCV_ISA_VENDOR_EXT_MAX_ANDES 32 | ||
|
||
extern struct riscv_isa_vendor_ext_data_list riscv_isa_vendor_ext_list_andes; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.