Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp902660pxk; Thu, 10 Sep 2020 01:24:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyHolbX/wc4IuxKkLBGHKSBMyjXUPZklKjeztj3cpslOAo+5J0MOcfa0EEJAEqXosfDETm1 X-Received: by 2002:a17:906:63c9:: with SMTP id u9mr7485197ejk.82.1599726240544; Thu, 10 Sep 2020 01:24:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599726240; cv=none; d=google.com; s=arc-20160816; b=B/A69VcIJ9U/gexuNAimcfh+zJ+DsihJexgb1fa+g/0qimVDPb1NfPQZxjo7F5pH+j GzzcpgkK1bLfjIQ2Tor7lM93X+tHlGUp8TcHpD5iBaEJ/1XjaR8g50bfasmFb5TmMST9 UKtsvhb8zQIJFi3R4Ehzlsy9alqcKSC6qLUz+SlLK/sIOMR05ScT+Co3CUSlj4EgfhGp tMZRml1Gz3rS/Bv9LkEATH979hEaPS0RmrB2gI7ZpKMkCYNcelOY98uZXQ5jOXkiY83H 3nG+6luKEUnhVvv3Bk7aS8vJrwbbrt6yJv6utd3z1VPkfgxPIQX8s4sQDQMQ8UK5g8dM smVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=b7nwVvrjTBVRtHppJqQAkiSfbar3bHistj9A5OWSP/U=; b=UVolL43j3JUoeqXttw8jvc5cSVKBPc+KC7yAhxj37Yjgctd5uhNoAzjnrhv6AlKVpD l1J6wtyhtNgtBpWh8UtCW+ph3hoNcWZdV8BuHLELOzLSgC/mNywMxbgNMLDGyYXhqytk YnjOJGXRDbwzbAbTn7jSYeBciXIhoh6AwIkhJus8sdzO70xU2uvK4fhIJN3A9dZDDj7Z VRnY+AJ+VYXYjhPl9pZAtjJO9kQM2n9TuM/3RlcGXnmTxn77hBu09k+IMrVGSlflAsXt odCpzQQNXBzH3NxCF6z0ZecbPhozY0OlIy9OkyV7PCW4SWxwDMcLg1NeVFh+FZzblh7C nwiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=IzQaAMMT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s3si3007517ejv.383.2020.09.10.01.23.37; Thu, 10 Sep 2020 01:24:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=IzQaAMMT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729135AbgIJIUs (ORCPT + 99 others); Thu, 10 Sep 2020 04:20:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728443AbgIJIMy (ORCPT ); Thu, 10 Sep 2020 04:12:54 -0400 Received: from mail-pl1-x641.google.com (mail-pl1-x641.google.com [IPv6:2607:f8b0:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB8D7C061757 for ; Thu, 10 Sep 2020 01:12:53 -0700 (PDT) Received: by mail-pl1-x641.google.com with SMTP id c3so540041plz.5 for ; Thu, 10 Sep 2020 01:12:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=b7nwVvrjTBVRtHppJqQAkiSfbar3bHistj9A5OWSP/U=; b=IzQaAMMT2j0UvYxCP6rnBPqQiDH2qMqu/NIuRa+EjILwwb4WLiqn9RspVzMJEVmpqE KOvyjCo2zxHnSrmKFpvawqwa71LiLQTLSpWaDO2xTBod4XGLkf5vWpbPAaMNxKnf4q8l 9rK8yOdPEF3V6yQRA8z+dzed8utlKxdCjPKpRwVdUYmePQdDWoUqWXzfklVial1oZGmN UhlIxxQUxSHiKXDf4uErygfu/LcnTm7X6CKHWpk2u7/PC97lfJQDPC1RE/gFHeb76eEU EVabX4/2FtFa/6GhAX62tqHrtef1/z2R9WGAm1UPUJMDU8k6eibMSg6aWEzc0X9Vmk0W OFfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=b7nwVvrjTBVRtHppJqQAkiSfbar3bHistj9A5OWSP/U=; b=aZUQi2cjZij0ncYFP0sUCK8poHxZ5GFxJaVCWJ8+sMpKlhqVR8LzXz4uelv09bm7ru UdakGlPVOvE7LRXVXKtwBVT+zgzFo8nXZLWAvRLtYye6DrEcy4kzy70BNVNJwokwKDXr KXRcaVtg0Bj9bCfp6eyEesREYKLsDxlOdLbaXOKmfd2q0hfEtDYFhBkcLmgaeJkeJckI bmvta/Jml2rTazALMpLsx+hKUnzdg7LtG6R5D9FqADSqtamGlrEMtW4DkJwyqmG3qygc 3LeyPhOn4gb74KhQF2s4zq5ipKgP/cAMob93decpXWuOQG+MQVecAmv5klP6GGTczuiI ONDw== X-Gm-Message-State: AOAM532vSEuDi57LpQJaLc/OOb+DbS23uMWqPk8JcMjtYmfG6SvcTm/x f1ftBi1pugHIyH9VPgp2tEafYA== X-Received: by 2002:a17:902:eb0b:b029:d1:8c50:b1ed with SMTP id l11-20020a170902eb0bb02900d18c50b1edmr1614334plb.41.1599725573393; Thu, 10 Sep 2020 01:12:53 -0700 (PDT) Received: from hsinchu02.internal.sifive.com (114-34-229-221.HINET-IP.hinet.net. [114.34.229.221]) by smtp.gmail.com with ESMTPSA id e1sm2196056pfl.162.2020.09.10.01.12.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2020 01:12:52 -0700 (PDT) From: Greentime Hu To: greentime.hu@sifive.com, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, aou@eecs.berkeley.edu, palmer@dabbelt.com, paul.walmsley@sifive.com Cc: Guo Ren Subject: [RFC PATCH v7 08/21] riscv: Add vector struct and assembler definitions Date: Thu, 10 Sep 2020 16:12:03 +0800 Message-Id: <4cb7ed8c6af8e1865ca817d590f06f4fb485230f.1599719352.git.greentime.hu@sifive.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. [guoren@linux.alibaba.com: first version vector porting] Signed-off-by: Greentime Hu Signed-off-by: Guo Ren --- arch/riscv/include/asm/processor.h | 1 + arch/riscv/include/uapi/asm/ptrace.h | 13 +++++++++++++ arch/riscv/kernel/asm-offsets.c | 8 ++++++++ 3 files changed, 22 insertions(+) diff --git a/arch/riscv/include/asm/processor.h b/arch/riscv/include/asm/processor.h index bdddcd5c1b71..a66a5d4ee5ad 100644 --- a/arch/riscv/include/asm/processor.h +++ b/arch/riscv/include/asm/processor.h @@ -34,6 +34,7 @@ struct thread_struct { unsigned long sp; /* Kernel mode stack */ unsigned long s[12]; /* s[0]: frame pointer */ struct __riscv_d_ext_state fstate; + struct __riscv_v_state vstate; }; #define INIT_THREAD { \ diff --git a/arch/riscv/include/uapi/asm/ptrace.h b/arch/riscv/include/uapi/asm/ptrace.h index 882547f6bd5c..661b0466b850 100644 --- a/arch/riscv/include/uapi/asm/ptrace.h +++ b/arch/riscv/include/uapi/asm/ptrace.h @@ -77,6 +77,19 @@ union __riscv_fp_state { struct __riscv_q_ext_state q; }; +struct __riscv_v_state { + __u32 magic; + __u32 size; + unsigned long vstart; + unsigned long vl; + unsigned long vtype; + unsigned long vcsr; + void *datap; +#if __riscv_xlen == 32 + __u32 __padding; +#endif +} __attribute__((aligned(16))); + #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 db203442c08f..f6fa65a6aaf0 100644 --- a/arch/riscv/kernel/asm-offsets.c +++ b/arch/riscv/kernel/asm-offsets.c @@ -67,6 +67,14 @@ void asm_offsets(void) OFFSET(TASK_THREAD_F31, task_struct, thread.fstate.f[31]); OFFSET(TASK_THREAD_FCSR, task_struct, thread.fstate.fcsr); + OFFSET(RISCV_V_STATE_MAGIC, __riscv_v_state, magic); + OFFSET(RISCV_V_STATE_SIZE, __riscv_v_state, size); + 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.28.0