Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp29188pxb; Wed, 29 Sep 2021 20:09:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwKMfN9Z8AtzzDDTG+5dWHuD/JHZhWL5C1p69wz9/GpBtCG4LamSNmKbxKwCd1CJHj+/z+U X-Received: by 2002:a05:6402:493:: with SMTP id k19mr4251128edv.386.1632971342512; Wed, 29 Sep 2021 20:09:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632971342; cv=none; d=google.com; s=arc-20160816; b=lm/qN84iqu1QNSw/qNjkJLRlyYl0JVSerOMm9MjfMiw+U2W+9+T3Q9r7U7mO+yxM1A fnIIw04iCRaLJpKD46H/zCuBowxFZ7N/tzMKsQt73ThvxCBE8mwkAlMY5UyB2lNj2gZg bh+VudCoGEADAb+X/P6vlSvE5eXx8HivF4Vyza8FY+Ha2lnFoDXDS4yKdnWGNLgb4zz+ UE2IJrSUxnXI7Jd9NxuFQNcf8ObbW+G/eqFpsiI/O9JcEuFJKKNdcSQTQb24IhuvsHPm IdCC1/89NqH6oPVMeVEPXFWfGM+t4HQ8gykuXsvzEw7tYQl6NcUiz1GCZPc9YpPhm7kO mq3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=FsYqypxg/dr8c8wkXcAf7I6Hd0FSlf0rtrIdWKourdU=; b=dsHFflwDG4GyKkdWageWH8F6XWR2BClG47nXG220Ee5e3j9hvM4xIh1gueTtNnKhju d0t4sYnOV18/fGfpHjQAhSN8FcgOImz6vJRkxth6+MffsYIXtrYw5IdLd/k67ivg38iz xyI6fxd/r9TlA0UExS3ChhMrFS5FER3mUoGTv9+/7vcDRSpFg1OvAiHr4LQURl+rH7e5 cO65NvGz86/56R64Ab3Rg3hgHdXDkSVQ5Kxl/9uCopm5w2AHXiJFwwhfYW0gmRz3RfLf iPgXUBcs+X96dtGoOIDlVR1ApYc9TAJM7+Z4tgw9JhdupiWtULOPQtqVInrGnHhPxJjW c9sA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=SaeqEH6g; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q23si2067526ejj.178.2021.09.29.20.08.39; Wed, 29 Sep 2021 20:09:02 -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=@gmail.com header.s=20210112 header.b=SaeqEH6g; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347869AbhI3Cje (ORCPT + 99 others); Wed, 29 Sep 2021 22:39:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347849AbhI3Cjd (ORCPT ); Wed, 29 Sep 2021 22:39:33 -0400 Received: from mail-vs1-xe2c.google.com (mail-vs1-xe2c.google.com [IPv6:2607:f8b0:4864:20::e2c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8995EC06161C for ; Wed, 29 Sep 2021 19:37:51 -0700 (PDT) Received: by mail-vs1-xe2c.google.com with SMTP id o124so5508261vsc.6 for ; Wed, 29 Sep 2021 19:37:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=FsYqypxg/dr8c8wkXcAf7I6Hd0FSlf0rtrIdWKourdU=; b=SaeqEH6gjhtWTbbPlvjvhTi0o4fUIWYNq0JW65SJw7siu39S0ZbRgRH0GVO3MAIXDX OVCLvjIO2Thku8+ZEgx/nJpEi+FylTNXWvk4enKtDlDFZ6qMQ9GYYwXYkR1ih/5e8FN9 Mlzhb4qYw8Dt2N0Rl4u5aI7rN5QLi4x7+S8u9q0UpRZX0sxEZO6KrqlbYVNoCeePZ96G VJoqkdMuAhk3ztVa5+SoPpgzXF8orXYDa+WtJTYv7v7xCQx/36rBM63ga2sdP71uUeI6 rROgxmQy5/Obuo1dWAE9XmrMaZbu0QedLkwAKDzDGke+ctKx60fE5mRVMtVl5vCdrKfT 5lkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=FsYqypxg/dr8c8wkXcAf7I6Hd0FSlf0rtrIdWKourdU=; b=bIPX8Rd1mU5BIYVE6Ea2l3xkPE6gL1xFMwfvZ6W6nydQj/kHTFKjKsJjeXv/CgVZ3U rRgzgHRXl/oiWQeJcFxJS7/x3i7/T/07OUaAc6OSgrzSLyuqA+3JK+NwhtWd5xirgj21 hWcUVSeJPlH6nBJRb8zabQ3ShAt6NllRprFvxG38nvR7J1cUxJJTw/htSE1WCXMETVyS RmUoV+V3rcek3+RkjjOerQt1ci+I5zwFOwe6b4nUeAtmbYEPCoTDKkSHvhIVbvxrfayy GF26eVoDmsaztgEVpbZ7aEJVxHPFDcF+hoPNiwHO2CHGBn1k0ZTIhrQwcYCqAOXTyktB +FYA== X-Gm-Message-State: AOAM532GheDSTi0Xzwul4C/3M2Z/6XGQIMkAbmegV5JQNqh7vcKN32vh PiMSdJwhWtIqLwqM5zHO4CSQIbm94rC6eZvJJScUqe2WRbyOyA== X-Received: by 2002:a67:f251:: with SMTP id y17mr2073492vsm.22.1632969470752; Wed, 29 Sep 2021 19:37:50 -0700 (PDT) MIME-Version: 1.0 References: <82fe07af09d223b33c8d4b8986939bcc0d7180a1.1631121222.git.greentime.hu@sifive.com> In-Reply-To: <82fe07af09d223b33c8d4b8986939bcc0d7180a1.1631121222.git.greentime.hu@sifive.com> From: Ley Foon Tan Date: Thu, 30 Sep 2021 10:37:39 +0800 Message-ID: Subject: Re: [RFC PATCH v8 11/21] riscv: Add sigcontext save/restore for vector To: Greentime Hu Cc: linux-riscv@lists.infradead.org, Linux Kernel Mailing List , aou@eecs.berkeley.edu, Palmer Dabbelt , Paul Walmsley , vincent.chen@sifive.com Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 9, 2021 at 1:49 AM Greentime Hu wrote: > > This patch adds sigcontext save/restore for vector. The vector registers > will be saved in datap pointer. The datap pointer will be allocated > dynamically when the task needs in kernel space. The datap pointer will > be set right after the __riscv_v_state data structure to save all the > vector registers in the signal handler stack. > > Co-developed-by: Vincent Chen > Signed-off-by: Vincent Chen > Signed-off-by: Greentime Hu > --- > arch/riscv/include/uapi/asm/sigcontext.h | 24 ++++ > arch/riscv/kernel/asm-offsets.c | 2 + > arch/riscv/kernel/setup.c | 4 + > arch/riscv/kernel/signal.c | 164 ++++++++++++++++++++++- > 4 files changed, 190 insertions(+), 4 deletions(-) > [....] > + > +static size_t cal_rt_frame_size(void) > +{ > + struct rt_sigframe __user *frame; > + static size_t frame_size; > + size_t total_context_size = 0; > + size_t sc_reserved_size = sizeof(frame->uc.uc_mcontext.__reserved); > + > + if (frame_size) > + goto done; > + > + frame_size = sizeof(*frame); > + > + if (has_vector) > + total_context_size += rvv_sc_size; > + /* Preserved a __riscv_ctx_hdr for END signal context header. */ > + total_context_size += sizeof(struct __riscv_ctx_hdr); > + > + if (total_context_size > sc_reserved_size) > + frame_size += (total_context_size - sc_reserved_size); > + > +done: > + return round_up(frame_size, 16); Hi Greentime, frame_size is static variable here, so it will preserve the value for the next calling to cal_rt_frame_size(). I think we need update frame_size before return, example: frame_size = round_up(frame_size, 16); return frame_size; Regards Ley Foon