Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp5987759rwb; Wed, 21 Sep 2022 15:47:57 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5UobgKEchpL+B/rDVlhPB/maA/5BPNvBgJO09Lq4O0YhgoPwqb/2LxKJOaAN/YeMUDLyUk X-Received: by 2002:a17:906:6a23:b0:782:e8:1b7d with SMTP id qw35-20020a1709066a2300b0078200e81b7dmr415977ejc.127.1663800477650; Wed, 21 Sep 2022 15:47:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663800477; cv=none; d=google.com; s=arc-20160816; b=Myd2sessEQ68ydDnDl7f2P8dkEuukzS+p8+vlzSaGfKISzUdUA52/OUTQ5WDCkL+XQ xSjEG137zrbJXqwf6UqyM3iRDHga1iVXAIQ82Xw8PuEgVcGT9vU21zIU2jeB7yXZ+s55 GJoEZ7TJE6nzsE7ih0FSRloqZw0UdmcQ1ZeRiEFGCFOhrFNELFUFIc0UDF+yErdVrDfG me3HvUtGNqDFvAx+940cQfmXGLEm89bANmWqjgvgykThng1r7CPM2TmTiZrubJEI1tDO yhMGYGXrGvt8GbA9AQ9YloYDMVlZrJ1mMiaeHSig3cdxe+kJoa5Q7MmDOP8JmFyOPFTS +b/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:from :dkim-signature; bh=BvXu+QXgzcKTzY7GQZ6McuBPlZWnkV19grD1UPI3mnI=; b=pz+A+RbreqhSqnkPnxTDtNiSsuNYKVjIqRVDKiNSTsEMEnDD8TpgHrxzcaHoNkQSlp x4z7RfTC+hIkTISSON18+OGiZXd5dbKRcTkcH01WqGRgzbPDZCfk6K4MewbnFTWHm0E2 uRZRXRkwKohHJgj0tusM6oRHIh1sDksz5l6PEI+rEOpFXJOPZtE+ZK64rY7EvgvBz6Ub RL2+iK+igJjPW06eosyzamRqX/KmSODcJPGOqwSTLba8d2ByFZTxDljFYuBpBgg3mlBK Z++XHPTv5eccDY5hSV1g4OykkLdu6YztE6l/qxl2zBWHoflCMp0NUqw6k9lj6U0AEW92 72DQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@rivosinc-com.20210112.gappssmtp.com header.s=20210112 header.b="2Zivm6A/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e13-20020a170906844d00b0077b2ad71224si3253231ejy.136.2022.09.21.15.47.26; Wed, 21 Sep 2022 15:47:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail header.i=@rivosinc-com.20210112.gappssmtp.com header.s=20210112 header.b="2Zivm6A/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230232AbiIUVtY (ORCPT + 99 others); Wed, 21 Sep 2022 17:49:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53050 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229935AbiIUVtV (ORCPT ); Wed, 21 Sep 2022 17:49:21 -0400 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F0BAA6C1F for ; Wed, 21 Sep 2022 14:49:21 -0700 (PDT) Received: by mail-pj1-x1031.google.com with SMTP id s90-20020a17090a2f6300b00203a685a1aaso172525pjd.1 for ; Wed, 21 Sep 2022 14:49:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=BvXu+QXgzcKTzY7GQZ6McuBPlZWnkV19grD1UPI3mnI=; b=2Zivm6A/Q9fjuFhqOz4aFrJ4mttfj+vMvGL/use9tWtM+iU/jGsErSU8dXfCdtWfor IUvGbh/ffs6oX/xp2q/MZQ70jVl31CD2HJY3vZAnoiuaQKaxYLcGlpLizNhlN8f3zwjY 1TT2Rm3DicHIEsCYrDfskgMjR5Ir0ddmdvotGyZ058jsMvazNk6LjNTJOypDRvMi2MCX St1FRq+x9do7SRC9girM6Wh4WIG2Tiv/LfyNa/kuAAg6xYIgD70dJNhJuPErOImfOdfd 5KrMTF84K1GmVIndglT2dW+pgBlozWo6kiFuI7G9rXOLRxDc21UPLEGZlNQP0FEwJWpf qHlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=BvXu+QXgzcKTzY7GQZ6McuBPlZWnkV19grD1UPI3mnI=; b=lBnPzDEfDOHrs5IaGWPoy0497l3oFbfxD+kjNjsEwTVqLmcEhhWrB3k51yaOjO7Ryf 30dHpvwHGVzjHiKlJM6MeWxhBeb293BBCGuWvQihdMyYw2XJNxG2RWC3Yp6gsI+lY2n5 ti9gHmF7NTXyl+YsrDFm5x/VJL9KPh2I5PrzKbHlFDGV/Mbi89QpDvEI0AUxe3IVTGJJ UUqDsHSfANgQQR6NvWNPY6P2+bQCjXhL4n7nZSBCRIvKjBfon2sd0n4pjKHbBDmTerVC sevIJoAQiSZxW4RFFWbnAAbZK75/w0J0u6ekpNe/wLOWQI7vsAEitmZhVDzwp8p5wZXR 7i3g== X-Gm-Message-State: ACrzQf3dZhFTOLWQi0y5ERHZYfcZtEFurvSl8FvsEhqukWNfDtlIIvOy xrVSMBEk7vzK6f9c6XgfGiOMsg== X-Received: by 2002:a17:903:2346:b0:178:4c17:eef7 with SMTP id c6-20020a170903234600b001784c17eef7mr129194plh.30.1663796960633; Wed, 21 Sep 2022 14:49:20 -0700 (PDT) Received: from stillson.ba.rivosinc.com ([66.220.2.162]) by smtp.gmail.com with ESMTPSA id k7-20020aa79727000000b005484d133127sm2634536pfg.129.2022.09.21.14.49.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Sep 2022 14:49:20 -0700 (PDT) From: Chris Stillson Cc: Greentime Hu , Vincent Chen , Paul Walmsley , Palmer Dabbelt , Albert Ou , Eric Biederman , Kees Cook , Anup Patel , Atish Patra , Oleg Nesterov , Guo Ren , Heinrich Schuchardt , Mayuresh Chitale , Conor Dooley , Chris Stillson , Paolo Bonzini , Qinglin Pan , Alexandre Ghiti , Arnd Bergmann , Heiko Stuebner , Dao Lu , Jisheng Zhang , Sunil V L , Han-Kuan Chen , Li Zhengyu , Changbin Du , Ard Biesheuvel , Tsukasa OI , Yury Norov , Nicolas Saenz Julienne , Mark Rutland , "Paul E. McKenney" , Frederic Weisbecker , Vitaly Wool , Myrtle Shah , Nick Knight , Catalin Marinas , Mark Brown , Will Deacon , Jiaxun Yang , Janosch Frank , Alexey Dobriyan , Huacai Chen , Christian Brauner , Andrew Morton , Colin Cross , Eugene Syromiatnikov , Peter Collingbourne , Barret Rhoden , Suren Baghdasaryan , Davidlohr Bueso , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, kvm@vger.kernel.org, kvm-riscv@lists.infradead.org Subject: [PATCH v12 07/17] riscv: Add vector struct and assembler definitions Date: Wed, 21 Sep 2022 14:43:49 -0700 Message-Id: <20220921214439.1491510-7-stillson@rivosinc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220921214439.1491510-1-stillson@rivosinc.com> References: <20220921214439.1491510-1-stillson@rivosinc.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Greentime Hu Add vector state context struct in struct thread and asm-offsets.c definitions. The vector registers will be saved in datap pointer of __riscv_v_state. It will be dynamically allocated in kernel space. It will be put right after the __riscv_v_state data structure in user space. Co-developed-by: Vincent Chen Signed-off-by: Vincent Chen Signed-off-by: Greentime Hu --- arch/riscv/include/asm/processor.h | 1 + arch/riscv/include/uapi/asm/ptrace.h | 17 +++++++++++++++++ arch/riscv/kernel/asm-offsets.c | 6 ++++++ 3 files changed, 24 insertions(+) diff --git a/arch/riscv/include/asm/processor.h b/arch/riscv/include/asm/processor.h index 19eedd4af4cd..95917a2b24f9 100644 --- a/arch/riscv/include/asm/processor.h +++ b/arch/riscv/include/asm/processor.h @@ -39,6 +39,7 @@ struct thread_struct { unsigned long s[12]; /* s[0]: frame pointer */ struct __riscv_d_ext_state fstate; unsigned long bad_cause; + struct __riscv_v_state vstate; }; /* Whitelist the fstate from the task_struct for hardened usercopy */ diff --git a/arch/riscv/include/uapi/asm/ptrace.h b/arch/riscv/include/uapi/asm/ptrace.h index 882547f6bd5c..6ee1ca2edfa7 100644 --- a/arch/riscv/include/uapi/asm/ptrace.h +++ b/arch/riscv/include/uapi/asm/ptrace.h @@ -77,6 +77,23 @@ union __riscv_fp_state { struct __riscv_q_ext_state q; }; +struct __riscv_v_state { + unsigned long vstart; + unsigned long vl; + unsigned long vtype; + unsigned long vcsr; + void *datap; + /* + * In signal handler, datap will be set a correct user stack offset + * and vector registers will be copied to the address of datap + * pointer. + * + * In ptrace syscall, datap will be set to zero and the vector + * registers will be copied to the address right after this + * structure. + */ +}; + #endif /* __ASSEMBLY__ */ #endif /* _UAPI_ASM_RISCV_PTRACE_H */ diff --git a/arch/riscv/kernel/asm-offsets.c b/arch/riscv/kernel/asm-offsets.c index df9444397908..37e3e6a8d877 100644 --- a/arch/riscv/kernel/asm-offsets.c +++ b/arch/riscv/kernel/asm-offsets.c @@ -75,6 +75,12 @@ void asm_offsets(void) OFFSET(TSK_STACK_CANARY, task_struct, stack_canary); #endif + OFFSET(RISCV_V_STATE_VSTART, __riscv_v_state, vstart); + OFFSET(RISCV_V_STATE_VL, __riscv_v_state, vl); + OFFSET(RISCV_V_STATE_VTYPE, __riscv_v_state, vtype); + OFFSET(RISCV_V_STATE_VCSR, __riscv_v_state, vcsr); + OFFSET(RISCV_V_STATE_DATAP, __riscv_v_state, datap); + DEFINE(PT_SIZE, sizeof(struct pt_regs)); OFFSET(PT_EPC, pt_regs, epc); OFFSET(PT_RA, pt_regs, ra); -- 2.25.1