diff mbox series

[v1,19/38] arm64/sme: Implement vector length configuration prctl()s

Message ID 20210930181144.10029-20-broonie@kernel.org
State New
Headers show
Series arm64/sme: Initial support for the Scalable Matrix Extension | expand

Commit Message

Mark Brown Sept. 30, 2021, 6:11 p.m. UTC
As for SVE provide a prctl() interface which allows processes to
configure their SME vector length.

Signed-off-by: Mark Brown <broonie@kernel.org>

---
 arch/arm64/include/asm/processor.h   |  4 +++-
 arch/arm64/include/asm/thread_info.h |  1 +
 arch/arm64/kernel/fpsimd.c           | 30 ++++++++++++++++++++++++++++
 include/uapi/linux/prctl.h           |  9 +++++++++
 kernel/sys.c                         |  6 ++++++
 5 files changed, 49 insertions(+), 1 deletion(-)

-- 
2.20.1

Comments

kernel test robot Oct. 1, 2021, 5:20 a.m. UTC | #1
Hi Mark,

I love your patch! Yet something to improve:

[auto build test ERROR on 8694e5e6388695195a32bd5746635ca166a8df56]

url:    https://github.com/0day-ci/linux/commits/Mark-Brown/arm64-sme-Initial-support-for-the-Scalable-Matrix-Extension/20211001-021749
base:   8694e5e6388695195a32bd5746635ca166a8df56
config: arc-randconfig-r043-20210930 (attached as .config)
compiler: arc-elf-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/f3b1bea56a1628668cc399d8eaae7ea4cacd8186
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Mark-Brown/arm64-sme-Initial-support-for-the-Scalable-Matrix-Extension/20211001-021749
        git checkout f3b1bea56a1628668cc399d8eaae7ea4cacd8186
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross ARCH=arc 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   kernel/sys.c: In function '__do_sys_prctl':
>> kernel/sys.c:2467:25: error: implicit declaration of function 'SME_SET_VL'; did you mean 'SVE_SET_VL'? [-Werror=implicit-function-declaration]

    2467 |                 error = SME_SET_VL(arg2);
         |                         ^~~~~~~~~~
         |                         SVE_SET_VL
>> kernel/sys.c:2470:25: error: implicit declaration of function 'SME_GET_VL'; did you mean 'SVE_GET_VL'? [-Werror=implicit-function-declaration]

    2470 |                 error = SME_GET_VL();
         |                         ^~~~~~~~~~
         |                         SVE_GET_VL
   In file included from include/linux/perf_event.h:25,
                    from kernel/sys.c:17:
   At top level:
   arch/arc/include/asm/perf_event.h:126:27: warning: 'arc_pmu_cache_map' defined but not used [-Wunused-const-variable=]
     126 | static const unsigned int arc_pmu_cache_map[C(MAX)][C(OP_MAX)][C(RESULT_MAX)] = {
         |                           ^~~~~~~~~~~~~~~~~
   arch/arc/include/asm/perf_event.h:91:27: warning: 'arc_pmu_ev_hw_map' defined but not used [-Wunused-const-variable=]
      91 | static const char * const arc_pmu_ev_hw_map[] = {
         |                           ^~~~~~~~~~~~~~~~~
   cc1: some warnings being treated as errors


vim +2467 kernel/sys.c

  2263	
  2264	SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3,
  2265			unsigned long, arg4, unsigned long, arg5)
  2266	{
  2267		struct task_struct *me = current;
  2268		unsigned char comm[sizeof(me->comm)];
  2269		long error;
  2270	
  2271		error = security_task_prctl(option, arg2, arg3, arg4, arg5);
  2272		if (error != -ENOSYS)
  2273			return error;
  2274	
  2275		error = 0;
  2276		switch (option) {
  2277		case PR_SET_PDEATHSIG:
  2278			if (!valid_signal(arg2)) {
  2279				error = -EINVAL;
  2280				break;
  2281			}
  2282			me->pdeath_signal = arg2;
  2283			break;
  2284		case PR_GET_PDEATHSIG:
  2285			error = put_user(me->pdeath_signal, (int __user *)arg2);
  2286			break;
  2287		case PR_GET_DUMPABLE:
  2288			error = get_dumpable(me->mm);
  2289			break;
  2290		case PR_SET_DUMPABLE:
  2291			if (arg2 != SUID_DUMP_DISABLE && arg2 != SUID_DUMP_USER) {
  2292				error = -EINVAL;
  2293				break;
  2294			}
  2295			set_dumpable(me->mm, arg2);
  2296			break;
  2297	
  2298		case PR_SET_UNALIGN:
  2299			error = SET_UNALIGN_CTL(me, arg2);
  2300			break;
  2301		case PR_GET_UNALIGN:
  2302			error = GET_UNALIGN_CTL(me, arg2);
  2303			break;
  2304		case PR_SET_FPEMU:
  2305			error = SET_FPEMU_CTL(me, arg2);
  2306			break;
  2307		case PR_GET_FPEMU:
  2308			error = GET_FPEMU_CTL(me, arg2);
  2309			break;
  2310		case PR_SET_FPEXC:
  2311			error = SET_FPEXC_CTL(me, arg2);
  2312			break;
  2313		case PR_GET_FPEXC:
  2314			error = GET_FPEXC_CTL(me, arg2);
  2315			break;
  2316		case PR_GET_TIMING:
  2317			error = PR_TIMING_STATISTICAL;
  2318			break;
  2319		case PR_SET_TIMING:
  2320			if (arg2 != PR_TIMING_STATISTICAL)
  2321				error = -EINVAL;
  2322			break;
  2323		case PR_SET_NAME:
  2324			comm[sizeof(me->comm) - 1] = 0;
  2325			if (strncpy_from_user(comm, (char __user *)arg2,
  2326					      sizeof(me->comm) - 1) < 0)
  2327				return -EFAULT;
  2328			set_task_comm(me, comm);
  2329			proc_comm_connector(me);
  2330			break;
  2331		case PR_GET_NAME:
  2332			get_task_comm(comm, me);
  2333			if (copy_to_user((char __user *)arg2, comm, sizeof(comm)))
  2334				return -EFAULT;
  2335			break;
  2336		case PR_GET_ENDIAN:
  2337			error = GET_ENDIAN(me, arg2);
  2338			break;
  2339		case PR_SET_ENDIAN:
  2340			error = SET_ENDIAN(me, arg2);
  2341			break;
  2342		case PR_GET_SECCOMP:
  2343			error = prctl_get_seccomp();
  2344			break;
  2345		case PR_SET_SECCOMP:
  2346			error = prctl_set_seccomp(arg2, (char __user *)arg3);
  2347			break;
  2348		case PR_GET_TSC:
  2349			error = GET_TSC_CTL(arg2);
  2350			break;
  2351		case PR_SET_TSC:
  2352			error = SET_TSC_CTL(arg2);
  2353			break;
  2354		case PR_TASK_PERF_EVENTS_DISABLE:
  2355			error = perf_event_task_disable();
  2356			break;
  2357		case PR_TASK_PERF_EVENTS_ENABLE:
  2358			error = perf_event_task_enable();
  2359			break;
  2360		case PR_GET_TIMERSLACK:
  2361			if (current->timer_slack_ns > ULONG_MAX)
  2362				error = ULONG_MAX;
  2363			else
  2364				error = current->timer_slack_ns;
  2365			break;
  2366		case PR_SET_TIMERSLACK:
  2367			if (arg2 <= 0)
  2368				current->timer_slack_ns =
  2369						current->default_timer_slack_ns;
  2370			else
  2371				current->timer_slack_ns = arg2;
  2372			break;
  2373		case PR_MCE_KILL:
  2374			if (arg4 | arg5)
  2375				return -EINVAL;
  2376			switch (arg2) {
  2377			case PR_MCE_KILL_CLEAR:
  2378				if (arg3 != 0)
  2379					return -EINVAL;
  2380				current->flags &= ~PF_MCE_PROCESS;
  2381				break;
  2382			case PR_MCE_KILL_SET:
  2383				current->flags |= PF_MCE_PROCESS;
  2384				if (arg3 == PR_MCE_KILL_EARLY)
  2385					current->flags |= PF_MCE_EARLY;
  2386				else if (arg3 == PR_MCE_KILL_LATE)
  2387					current->flags &= ~PF_MCE_EARLY;
  2388				else if (arg3 == PR_MCE_KILL_DEFAULT)
  2389					current->flags &=
  2390							~(PF_MCE_EARLY|PF_MCE_PROCESS);
  2391				else
  2392					return -EINVAL;
  2393				break;
  2394			default:
  2395				return -EINVAL;
  2396			}
  2397			break;
  2398		case PR_MCE_KILL_GET:
  2399			if (arg2 | arg3 | arg4 | arg5)
  2400				return -EINVAL;
  2401			if (current->flags & PF_MCE_PROCESS)
  2402				error = (current->flags & PF_MCE_EARLY) ?
  2403					PR_MCE_KILL_EARLY : PR_MCE_KILL_LATE;
  2404			else
  2405				error = PR_MCE_KILL_DEFAULT;
  2406			break;
  2407		case PR_SET_MM:
  2408			error = prctl_set_mm(arg2, arg3, arg4, arg5);
  2409			break;
  2410		case PR_GET_TID_ADDRESS:
  2411			error = prctl_get_tid_address(me, (int __user * __user *)arg2);
  2412			break;
  2413		case PR_SET_CHILD_SUBREAPER:
  2414			me->signal->is_child_subreaper = !!arg2;
  2415			if (!arg2)
  2416				break;
  2417	
  2418			walk_process_tree(me, propagate_has_child_subreaper, NULL);
  2419			break;
  2420		case PR_GET_CHILD_SUBREAPER:
  2421			error = put_user(me->signal->is_child_subreaper,
  2422					 (int __user *)arg2);
  2423			break;
  2424		case PR_SET_NO_NEW_PRIVS:
  2425			if (arg2 != 1 || arg3 || arg4 || arg5)
  2426				return -EINVAL;
  2427	
  2428			task_set_no_new_privs(current);
  2429			break;
  2430		case PR_GET_NO_NEW_PRIVS:
  2431			if (arg2 || arg3 || arg4 || arg5)
  2432				return -EINVAL;
  2433			return task_no_new_privs(current) ? 1 : 0;
  2434		case PR_GET_THP_DISABLE:
  2435			if (arg2 || arg3 || arg4 || arg5)
  2436				return -EINVAL;
  2437			error = !!test_bit(MMF_DISABLE_THP, &me->mm->flags);
  2438			break;
  2439		case PR_SET_THP_DISABLE:
  2440			if (arg3 || arg4 || arg5)
  2441				return -EINVAL;
  2442			if (mmap_write_lock_killable(me->mm))
  2443				return -EINTR;
  2444			if (arg2)
  2445				set_bit(MMF_DISABLE_THP, &me->mm->flags);
  2446			else
  2447				clear_bit(MMF_DISABLE_THP, &me->mm->flags);
  2448			mmap_write_unlock(me->mm);
  2449			break;
  2450		case PR_MPX_ENABLE_MANAGEMENT:
  2451		case PR_MPX_DISABLE_MANAGEMENT:
  2452			/* No longer implemented: */
  2453			return -EINVAL;
  2454		case PR_SET_FP_MODE:
  2455			error = SET_FP_MODE(me, arg2);
  2456			break;
  2457		case PR_GET_FP_MODE:
  2458			error = GET_FP_MODE(me);
  2459			break;
  2460		case PR_SVE_SET_VL:
  2461			error = SVE_SET_VL(arg2);
  2462			break;
  2463		case PR_SVE_GET_VL:
  2464			error = SVE_GET_VL();
  2465			break;
  2466		case PR_SME_SET_VL:
> 2467			error = SME_SET_VL(arg2);

  2468			break;
  2469		case PR_SME_GET_VL:
> 2470			error = SME_GET_VL();

  2471			break;
  2472		case PR_GET_SPECULATION_CTRL:
  2473			if (arg3 || arg4 || arg5)
  2474				return -EINVAL;
  2475			error = arch_prctl_spec_ctrl_get(me, arg2);
  2476			break;
  2477		case PR_SET_SPECULATION_CTRL:
  2478			if (arg4 || arg5)
  2479				return -EINVAL;
  2480			error = arch_prctl_spec_ctrl_set(me, arg2, arg3);
  2481			break;
  2482		case PR_PAC_RESET_KEYS:
  2483			if (arg3 || arg4 || arg5)
  2484				return -EINVAL;
  2485			error = PAC_RESET_KEYS(me, arg2);
  2486			break;
  2487		case PR_PAC_SET_ENABLED_KEYS:
  2488			if (arg4 || arg5)
  2489				return -EINVAL;
  2490			error = PAC_SET_ENABLED_KEYS(me, arg2, arg3);
  2491			break;
  2492		case PR_PAC_GET_ENABLED_KEYS:
  2493			if (arg2 || arg3 || arg4 || arg5)
  2494				return -EINVAL;
  2495			error = PAC_GET_ENABLED_KEYS(me);
  2496			break;
  2497		case PR_SET_TAGGED_ADDR_CTRL:
  2498			if (arg3 || arg4 || arg5)
  2499				return -EINVAL;
  2500			error = SET_TAGGED_ADDR_CTRL(arg2);
  2501			break;
  2502		case PR_GET_TAGGED_ADDR_CTRL:
  2503			if (arg2 || arg3 || arg4 || arg5)
  2504				return -EINVAL;
  2505			error = GET_TAGGED_ADDR_CTRL();
  2506			break;
  2507		case PR_SET_IO_FLUSHER:
  2508			if (!capable(CAP_SYS_RESOURCE))
  2509				return -EPERM;
  2510	
  2511			if (arg3 || arg4 || arg5)
  2512				return -EINVAL;
  2513	
  2514			if (arg2 == 1)
  2515				current->flags |= PR_IO_FLUSHER;
  2516			else if (!arg2)
  2517				current->flags &= ~PR_IO_FLUSHER;
  2518			else
  2519				return -EINVAL;
  2520			break;
  2521		case PR_GET_IO_FLUSHER:
  2522			if (!capable(CAP_SYS_RESOURCE))
  2523				return -EPERM;
  2524	
  2525			if (arg2 || arg3 || arg4 || arg5)
  2526				return -EINVAL;
  2527	
  2528			error = (current->flags & PR_IO_FLUSHER) == PR_IO_FLUSHER;
  2529			break;
  2530		case PR_SET_SYSCALL_USER_DISPATCH:
  2531			error = set_syscall_user_dispatch(arg2, arg3, arg4,
  2532							  (char __user *) arg5);
  2533			break;
  2534	#ifdef CONFIG_SCHED_CORE
  2535		case PR_SCHED_CORE:
  2536			error = sched_core_share_pid(arg2, arg3, arg4, arg5);
  2537			break;
  2538	#endif
  2539		default:
  2540			error = -EINVAL;
  2541			break;
  2542		}
  2543		return error;
  2544	}
  2545	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
Mark Brown Oct. 1, 2021, 12:40 p.m. UTC | #2
On Fri, Oct 01, 2021 at 01:20:12PM +0800, kernel test robot wrote:

> config: arc-randconfig-r043-20210930 (attached as .config)

> compiler: arc-elf-gcc (GCC) 11.2.0


I suspect you're reporting architectures in alphabetical order - can I
suggest making a priority list of widely used architectures?  I know I
tend to zone out issues which look like they only occur on less actively
maintained architectures as some of them have odd architecture specific
issues that really need to be fixed at the architecture level.
kernel test robot Oct. 1, 2021, 4:38 p.m. UTC | #3
Hi Mark,

I love your patch! Yet something to improve:

[auto build test ERROR on 8694e5e6388695195a32bd5746635ca166a8df56]

url:    https://github.com/0day-ci/linux/commits/Mark-Brown/arm64-sme-Initial-support-for-the-Scalable-Matrix-Extension/20211001-021749
base:   8694e5e6388695195a32bd5746635ca166a8df56
config: arm64-randconfig-r024-20210930 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 962e503cc8bc411f7523cc393acae8aae425b1c4)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install arm64 cross compiling tool for clang build
        # apt-get install binutils-aarch64-linux-gnu
        # https://github.com/0day-ci/linux/commit/f3b1bea56a1628668cc399d8eaae7ea4cacd8186
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Mark-Brown/arm64-sme-Initial-support-for-the-Scalable-Matrix-Extension/20211001-021749
        git checkout f3b1bea56a1628668cc399d8eaae7ea4cacd8186
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 ARCH=arm64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

>> kernel/sys.c:2467:11: error: implicit declaration of function 'sme_set_current_vl' [-Werror,-Wimplicit-function-declaration]

                   error = SME_SET_VL(arg2);
                           ^
   arch/arm64/include/asm/processor.h:360:25: note: expanded from macro 'SME_SET_VL'
   #define SME_SET_VL(arg) sme_set_current_vl(arg)
                           ^
   kernel/sys.c:2467:11: note: did you mean 'sve_set_current_vl'?
   arch/arm64/include/asm/processor.h:360:25: note: expanded from macro 'SME_SET_VL'
   #define SME_SET_VL(arg) sme_set_current_vl(arg)
                           ^
   arch/arm64/include/asm/fpsimd.h:236:19: note: 'sve_set_current_vl' declared here
   static inline int sve_set_current_vl(unsigned long arg)
                     ^
>> kernel/sys.c:2470:11: error: implicit declaration of function 'sme_get_current_vl' [-Werror,-Wimplicit-function-declaration]

                   error = SME_GET_VL();
                           ^
   arch/arm64/include/asm/processor.h:361:22: note: expanded from macro 'SME_GET_VL'
   #define SME_GET_VL()    sme_get_current_vl()
                           ^
   2 errors generated.


vim +/sme_set_current_vl +2467 kernel/sys.c

  2263	
  2264	SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3,
  2265			unsigned long, arg4, unsigned long, arg5)
  2266	{
  2267		struct task_struct *me = current;
  2268		unsigned char comm[sizeof(me->comm)];
  2269		long error;
  2270	
  2271		error = security_task_prctl(option, arg2, arg3, arg4, arg5);
  2272		if (error != -ENOSYS)
  2273			return error;
  2274	
  2275		error = 0;
  2276		switch (option) {
  2277		case PR_SET_PDEATHSIG:
  2278			if (!valid_signal(arg2)) {
  2279				error = -EINVAL;
  2280				break;
  2281			}
  2282			me->pdeath_signal = arg2;
  2283			break;
  2284		case PR_GET_PDEATHSIG:
  2285			error = put_user(me->pdeath_signal, (int __user *)arg2);
  2286			break;
  2287		case PR_GET_DUMPABLE:
  2288			error = get_dumpable(me->mm);
  2289			break;
  2290		case PR_SET_DUMPABLE:
  2291			if (arg2 != SUID_DUMP_DISABLE && arg2 != SUID_DUMP_USER) {
  2292				error = -EINVAL;
  2293				break;
  2294			}
  2295			set_dumpable(me->mm, arg2);
  2296			break;
  2297	
  2298		case PR_SET_UNALIGN:
  2299			error = SET_UNALIGN_CTL(me, arg2);
  2300			break;
  2301		case PR_GET_UNALIGN:
  2302			error = GET_UNALIGN_CTL(me, arg2);
  2303			break;
  2304		case PR_SET_FPEMU:
  2305			error = SET_FPEMU_CTL(me, arg2);
  2306			break;
  2307		case PR_GET_FPEMU:
  2308			error = GET_FPEMU_CTL(me, arg2);
  2309			break;
  2310		case PR_SET_FPEXC:
  2311			error = SET_FPEXC_CTL(me, arg2);
  2312			break;
  2313		case PR_GET_FPEXC:
  2314			error = GET_FPEXC_CTL(me, arg2);
  2315			break;
  2316		case PR_GET_TIMING:
  2317			error = PR_TIMING_STATISTICAL;
  2318			break;
  2319		case PR_SET_TIMING:
  2320			if (arg2 != PR_TIMING_STATISTICAL)
  2321				error = -EINVAL;
  2322			break;
  2323		case PR_SET_NAME:
  2324			comm[sizeof(me->comm) - 1] = 0;
  2325			if (strncpy_from_user(comm, (char __user *)arg2,
  2326					      sizeof(me->comm) - 1) < 0)
  2327				return -EFAULT;
  2328			set_task_comm(me, comm);
  2329			proc_comm_connector(me);
  2330			break;
  2331		case PR_GET_NAME:
  2332			get_task_comm(comm, me);
  2333			if (copy_to_user((char __user *)arg2, comm, sizeof(comm)))
  2334				return -EFAULT;
  2335			break;
  2336		case PR_GET_ENDIAN:
  2337			error = GET_ENDIAN(me, arg2);
  2338			break;
  2339		case PR_SET_ENDIAN:
  2340			error = SET_ENDIAN(me, arg2);
  2341			break;
  2342		case PR_GET_SECCOMP:
  2343			error = prctl_get_seccomp();
  2344			break;
  2345		case PR_SET_SECCOMP:
  2346			error = prctl_set_seccomp(arg2, (char __user *)arg3);
  2347			break;
  2348		case PR_GET_TSC:
  2349			error = GET_TSC_CTL(arg2);
  2350			break;
  2351		case PR_SET_TSC:
  2352			error = SET_TSC_CTL(arg2);
  2353			break;
  2354		case PR_TASK_PERF_EVENTS_DISABLE:
  2355			error = perf_event_task_disable();
  2356			break;
  2357		case PR_TASK_PERF_EVENTS_ENABLE:
  2358			error = perf_event_task_enable();
  2359			break;
  2360		case PR_GET_TIMERSLACK:
  2361			if (current->timer_slack_ns > ULONG_MAX)
  2362				error = ULONG_MAX;
  2363			else
  2364				error = current->timer_slack_ns;
  2365			break;
  2366		case PR_SET_TIMERSLACK:
  2367			if (arg2 <= 0)
  2368				current->timer_slack_ns =
  2369						current->default_timer_slack_ns;
  2370			else
  2371				current->timer_slack_ns = arg2;
  2372			break;
  2373		case PR_MCE_KILL:
  2374			if (arg4 | arg5)
  2375				return -EINVAL;
  2376			switch (arg2) {
  2377			case PR_MCE_KILL_CLEAR:
  2378				if (arg3 != 0)
  2379					return -EINVAL;
  2380				current->flags &= ~PF_MCE_PROCESS;
  2381				break;
  2382			case PR_MCE_KILL_SET:
  2383				current->flags |= PF_MCE_PROCESS;
  2384				if (arg3 == PR_MCE_KILL_EARLY)
  2385					current->flags |= PF_MCE_EARLY;
  2386				else if (arg3 == PR_MCE_KILL_LATE)
  2387					current->flags &= ~PF_MCE_EARLY;
  2388				else if (arg3 == PR_MCE_KILL_DEFAULT)
  2389					current->flags &=
  2390							~(PF_MCE_EARLY|PF_MCE_PROCESS);
  2391				else
  2392					return -EINVAL;
  2393				break;
  2394			default:
  2395				return -EINVAL;
  2396			}
  2397			break;
  2398		case PR_MCE_KILL_GET:
  2399			if (arg2 | arg3 | arg4 | arg5)
  2400				return -EINVAL;
  2401			if (current->flags & PF_MCE_PROCESS)
  2402				error = (current->flags & PF_MCE_EARLY) ?
  2403					PR_MCE_KILL_EARLY : PR_MCE_KILL_LATE;
  2404			else
  2405				error = PR_MCE_KILL_DEFAULT;
  2406			break;
  2407		case PR_SET_MM:
  2408			error = prctl_set_mm(arg2, arg3, arg4, arg5);
  2409			break;
  2410		case PR_GET_TID_ADDRESS:
  2411			error = prctl_get_tid_address(me, (int __user * __user *)arg2);
  2412			break;
  2413		case PR_SET_CHILD_SUBREAPER:
  2414			me->signal->is_child_subreaper = !!arg2;
  2415			if (!arg2)
  2416				break;
  2417	
  2418			walk_process_tree(me, propagate_has_child_subreaper, NULL);
  2419			break;
  2420		case PR_GET_CHILD_SUBREAPER:
  2421			error = put_user(me->signal->is_child_subreaper,
  2422					 (int __user *)arg2);
  2423			break;
  2424		case PR_SET_NO_NEW_PRIVS:
  2425			if (arg2 != 1 || arg3 || arg4 || arg5)
  2426				return -EINVAL;
  2427	
  2428			task_set_no_new_privs(current);
  2429			break;
  2430		case PR_GET_NO_NEW_PRIVS:
  2431			if (arg2 || arg3 || arg4 || arg5)
  2432				return -EINVAL;
  2433			return task_no_new_privs(current) ? 1 : 0;
  2434		case PR_GET_THP_DISABLE:
  2435			if (arg2 || arg3 || arg4 || arg5)
  2436				return -EINVAL;
  2437			error = !!test_bit(MMF_DISABLE_THP, &me->mm->flags);
  2438			break;
  2439		case PR_SET_THP_DISABLE:
  2440			if (arg3 || arg4 || arg5)
  2441				return -EINVAL;
  2442			if (mmap_write_lock_killable(me->mm))
  2443				return -EINTR;
  2444			if (arg2)
  2445				set_bit(MMF_DISABLE_THP, &me->mm->flags);
  2446			else
  2447				clear_bit(MMF_DISABLE_THP, &me->mm->flags);
  2448			mmap_write_unlock(me->mm);
  2449			break;
  2450		case PR_MPX_ENABLE_MANAGEMENT:
  2451		case PR_MPX_DISABLE_MANAGEMENT:
  2452			/* No longer implemented: */
  2453			return -EINVAL;
  2454		case PR_SET_FP_MODE:
  2455			error = SET_FP_MODE(me, arg2);
  2456			break;
  2457		case PR_GET_FP_MODE:
  2458			error = GET_FP_MODE(me);
  2459			break;
  2460		case PR_SVE_SET_VL:
  2461			error = SVE_SET_VL(arg2);
  2462			break;
  2463		case PR_SVE_GET_VL:
  2464			error = SVE_GET_VL();
  2465			break;
  2466		case PR_SME_SET_VL:
> 2467			error = SME_SET_VL(arg2);

  2468			break;
  2469		case PR_SME_GET_VL:
> 2470			error = SME_GET_VL();

  2471			break;
  2472		case PR_GET_SPECULATION_CTRL:
  2473			if (arg3 || arg4 || arg5)
  2474				return -EINVAL;
  2475			error = arch_prctl_spec_ctrl_get(me, arg2);
  2476			break;
  2477		case PR_SET_SPECULATION_CTRL:
  2478			if (arg4 || arg5)
  2479				return -EINVAL;
  2480			error = arch_prctl_spec_ctrl_set(me, arg2, arg3);
  2481			break;
  2482		case PR_PAC_RESET_KEYS:
  2483			if (arg3 || arg4 || arg5)
  2484				return -EINVAL;
  2485			error = PAC_RESET_KEYS(me, arg2);
  2486			break;
  2487		case PR_PAC_SET_ENABLED_KEYS:
  2488			if (arg4 || arg5)
  2489				return -EINVAL;
  2490			error = PAC_SET_ENABLED_KEYS(me, arg2, arg3);
  2491			break;
  2492		case PR_PAC_GET_ENABLED_KEYS:
  2493			if (arg2 || arg3 || arg4 || arg5)
  2494				return -EINVAL;
  2495			error = PAC_GET_ENABLED_KEYS(me);
  2496			break;
  2497		case PR_SET_TAGGED_ADDR_CTRL:
  2498			if (arg3 || arg4 || arg5)
  2499				return -EINVAL;
  2500			error = SET_TAGGED_ADDR_CTRL(arg2);
  2501			break;
  2502		case PR_GET_TAGGED_ADDR_CTRL:
  2503			if (arg2 || arg3 || arg4 || arg5)
  2504				return -EINVAL;
  2505			error = GET_TAGGED_ADDR_CTRL();
  2506			break;
  2507		case PR_SET_IO_FLUSHER:
  2508			if (!capable(CAP_SYS_RESOURCE))
  2509				return -EPERM;
  2510	
  2511			if (arg3 || arg4 || arg5)
  2512				return -EINVAL;
  2513	
  2514			if (arg2 == 1)
  2515				current->flags |= PR_IO_FLUSHER;
  2516			else if (!arg2)
  2517				current->flags &= ~PR_IO_FLUSHER;
  2518			else
  2519				return -EINVAL;
  2520			break;
  2521		case PR_GET_IO_FLUSHER:
  2522			if (!capable(CAP_SYS_RESOURCE))
  2523				return -EPERM;
  2524	
  2525			if (arg2 || arg3 || arg4 || arg5)
  2526				return -EINVAL;
  2527	
  2528			error = (current->flags & PR_IO_FLUSHER) == PR_IO_FLUSHER;
  2529			break;
  2530		case PR_SET_SYSCALL_USER_DISPATCH:
  2531			error = set_syscall_user_dispatch(arg2, arg3, arg4,
  2532							  (char __user *) arg5);
  2533			break;
  2534	#ifdef CONFIG_SCHED_CORE
  2535		case PR_SCHED_CORE:
  2536			error = sched_core_share_pid(arg2, arg3, arg4, arg5);
  2537			break;
  2538	#endif
  2539		default:
  2540			error = -EINVAL;
  2541			break;
  2542		}
  2543		return error;
  2544	}
  2545	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
kernel test robot Oct. 8, 2021, 1:32 a.m. UTC | #4
On 10/1/2021 8:40 PM, Mark Brown wrote:
> On Fri, Oct 01, 2021 at 01:20:12PM +0800, kernel test robot wrote:

> 

>> config: arc-randconfig-r043-20210930 (attached as .config)

>> compiler: arc-elf-gcc (GCC) 11.2.0

> 

> I suspect you're reporting architectures in alphabetical order - can I

> suggest making a priority list of widely used architectures?  I know I

> tend to zone out issues which look like they only occur on less actively

> maintained architectures as some of them have odd architecture specific

> issues that really need to be fixed at the architecture level.

> 

> 


Hi Mark,

Thanks for your advice, we run the tests on different architectures
randomly for now, and we'll consider a priority list of widely used
architectures.

Best Regards,
Rong Chen
diff mbox series

Patch

diff --git a/arch/arm64/include/asm/processor.h b/arch/arm64/include/asm/processor.h
index 575a1fe719b7..a62d2f8045bf 100644
--- a/arch/arm64/include/asm/processor.h
+++ b/arch/arm64/include/asm/processor.h
@@ -354,9 +354,11 @@  extern void __init minsigstksz_setup(void);
  */
 #include <asm/fpsimd.h>
 
-/* Userspace interface for PR_SVE_{SET,GET}_VL prctl()s: */
+/* Userspace interface for PR_S[MV]E_{SET,GET}_VL prctl()s: */
 #define SVE_SET_VL(arg)	sve_set_current_vl(arg)
 #define SVE_GET_VL()	sve_get_current_vl()
+#define SME_SET_VL(arg)	sme_set_current_vl(arg)
+#define SME_GET_VL()	sme_get_current_vl()
 
 /* PR_PAC_RESET_KEYS prctl */
 #define PAC_RESET_KEYS(tsk, arg)	ptrauth_prctl_reset_keys(tsk, arg)
diff --git a/arch/arm64/include/asm/thread_info.h b/arch/arm64/include/asm/thread_info.h
index d5c8ac81ce11..5c4355204f4a 100644
--- a/arch/arm64/include/asm/thread_info.h
+++ b/arch/arm64/include/asm/thread_info.h
@@ -81,6 +81,7 @@  int arch_dup_task_struct(struct task_struct *dst,
 #define TIF_SVE_VL_INHERIT	24	/* Inherit SVE vl_onexec across exec */
 #define TIF_SSBD		25	/* Wants SSB mitigation */
 #define TIF_TAGGED_ADDR		26	/* Allow tagged user addresses */
+#define TIF_SME_VL_INHERIT	28	/* Inherit SME vl_onexec across exec */
 
 #define _TIF_SIGPENDING		(1 << TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1 << TIF_NEED_RESCHED)
diff --git a/arch/arm64/kernel/fpsimd.c b/arch/arm64/kernel/fpsimd.c
index 13df5920fe1e..9511428c2e81 100644
--- a/arch/arm64/kernel/fpsimd.c
+++ b/arch/arm64/kernel/fpsimd.c
@@ -145,6 +145,8 @@  static unsigned int vec_vl_inherit_flag(enum vec_type type)
 	switch (type) {
 	case ARM64_VEC_SVE:
 		return TIF_SVE_VL_INHERIT;
+	case ARM64_VEC_SME:
+		return TIF_SME_VL_INHERIT;
 	default:
 		WARN_ON_ONCE(1);
 		return 0;
@@ -800,6 +802,34 @@  int sve_get_current_vl(void)
 	return vec_prctl_status(ARM64_VEC_SVE, 0);
 }
 
+/* PR_SME_SET_VL */
+int sme_set_current_vl(unsigned long arg)
+{
+	unsigned long vl, flags;
+	int ret;
+
+	vl = arg & PR_SME_VL_LEN_MASK;
+	flags = arg & ~vl;
+
+	if (!system_supports_sme() || is_compat_task())
+		return -EINVAL;
+
+	ret = vec_set_vector_length(current, ARM64_VEC_SME, vl, flags);
+	if (ret)
+		return ret;
+
+	return vec_prctl_status(ARM64_VEC_SME, flags);
+}
+
+/* PR_SME_GET_VL */
+int sme_get_current_vl(void)
+{
+	if (!system_supports_sme() || is_compat_task())
+		return -EINVAL;
+
+	return vec_prctl_status(ARM64_VEC_SME, 0);
+}
+
 static void vec_probe_vqs(struct vl_info *info,
 			  DECLARE_BITMAP(map, SVE_VQ_MAX))
 {
diff --git a/include/uapi/linux/prctl.h b/include/uapi/linux/prctl.h
index 43bd7f713c39..b3212d73c198 100644
--- a/include/uapi/linux/prctl.h
+++ b/include/uapi/linux/prctl.h
@@ -269,4 +269,13 @@  struct prctl_mm_map {
 # define PR_SCHED_CORE_SHARE_FROM	3 /* pull core_sched cookie to pid */
 # define PR_SCHED_CORE_MAX		4
 
+/* arm64 Scalable Matrix Extension controls */
+/* Flag values must be in sync with SVE versions */
+#define PR_SME_SET_VL			63	/* set task vector length */
+# define PR_SME_SET_VL_ONEXEC		(1 << 18) /* defer effect until exec */
+#define PR_SME_GET_VL			64	/* get task vector length */
+/* Bits common to PR_SME_SET_VL and PR_SME_GET_VL */
+# define PR_SME_VL_LEN_MASK		0xffff
+# define PR_SME_VL_INHERIT		(1 << 17) /* inherit across exec */
+
 #endif /* _LINUX_PRCTL_H */
diff --git a/kernel/sys.c b/kernel/sys.c
index 8fdac0d90504..bf45194ce03b 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -2463,6 +2463,12 @@  SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3,
 	case PR_SVE_GET_VL:
 		error = SVE_GET_VL();
 		break;
+	case PR_SME_SET_VL:
+		error = SME_SET_VL(arg2);
+		break;
+	case PR_SME_GET_VL:
+		error = SME_GET_VL();
+		break;
 	case PR_GET_SPECULATION_CTRL:
 		if (arg3 || arg4 || arg5)
 			return -EINVAL;