From patchwork Wed Apr 28 19:34:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 428622 Delivered-To: patch@linaro.org Received: by 2002:a02:c901:0:0:0:0:0 with SMTP id t1csp936543jao; Wed, 28 Apr 2021 12:55:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzAJWZatymN4sAaCkc9t0NakPm9dQaebpprswlNjxgD9qDUNcJAjYaIQyDLjqEHio79aR88 X-Received: by 2002:a92:da8a:: with SMTP id u10mr24841639iln.100.1619639719662; Wed, 28 Apr 2021 12:55:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619639719; cv=none; d=google.com; s=arc-20160816; b=kFmj7HENVAQ0qMmWZqUPcSJQ9Q5/ta/Ot2jLueMBt3JMq0kjVQw6yl0nMB3wP7lKWm 6RDfECygTysn8SynBFuWvMY/iBzgNDjf3wy9T9KjVW3CoGZA8rZdeZwBOEZb0oeD8/UI P4rlJPVUHXsdspx1cH6HqeE6QmQu4hWL5elTxPo0CagC+r2Se7kZs0rtN4jzTSkOip6r oTqONaDYOq2+8MJxCyQMr77B4Sb9Jb5jFmdqy+wO4q9H9YWy6Em5OX7d+CtstzoP750P m18pp6f3hSXkZRcSk2jvBa7GqZbkM/tLr1sCxOUeCNDmW5ZtAJ33Q5pcmd23aiznyv49 XuxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=ld1aOOPFCTaDlIM4pseMTjUT2N/AiXsA3fl7Bo9Xfu4=; b=EL+CK8ZKJVXaMOlihucCJEGB8CT9jTEw/ZElHi549HTR6FyJjOsfSUHyPDKPXX2KhI 0cYF8tOPvh4rx9vz4fhTo4QsVzmqVQVDmaZRSE0t6y4cdiG+b7OkJDNSsN/YldgnvsQ8 WcKvNWQsfEf6pRVsqxlUR/7x0qV7WxAWVWXtz6LDInwoPqvi6xrf6HoTxDJv3mXYaqOB fHpT282hr6uG/RMdyZMEKxBZ2+XGt0WbNeUksHa9bVNguIqojTUke1idf0oEKiROI2CS etvUrfUk54DyAFh/4kMZ9BVtmg/tmuIp7NipKZTWLbpCFiilSgzAwH3/Bl3n0RQ0OlKW Jy0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=PC4rOSN5; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d8si1003428ioy.104.2021.04.28.12.55.19 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 28 Apr 2021 12:55:19 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=PC4rOSN5; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:41466 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lbqHH-0001Ja-3e for patch@linaro.org; Wed, 28 Apr 2021 15:55:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55404) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lbpxG-00065a-MN for qemu-devel@nongnu.org; Wed, 28 Apr 2021 15:34:38 -0400 Received: from mail-pj1-x1029.google.com ([2607:f8b0:4864:20::1029]:41761) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lbpwy-0004j3-Bn for qemu-devel@nongnu.org; Wed, 28 Apr 2021 15:34:38 -0400 Received: by mail-pj1-x1029.google.com with SMTP id y22-20020a17090a8b16b0290150ae1a6d2bso9699299pjn.0 for ; Wed, 28 Apr 2021 12:34:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ld1aOOPFCTaDlIM4pseMTjUT2N/AiXsA3fl7Bo9Xfu4=; b=PC4rOSN52eqF1IWhTmwsVrG2RyppGJdWOOkCljx/JFXuiJjNaJe8gyJ0n42aLYRYsR 7l9FU1dQaMgj9bbqqBD+oZQUCQ0mIiSqXsIPO9K0GySJe1ZCBrtmPRUNtVk4izBG7m+A QSVSpmN6lGbnmv2nCl+bmil/dR/dY0Q0Q9MKogeXFFrOkJKOgFEaGmjpaFqJ5Q8CrML/ HoA2iuOgK7vfnjyjJivXGu4wWTqo2GfT9YG8SysSLyerkCiLvOwakUNcnKUMcuE0ySUe swsoaZ51jbVgr0aZJ2kcRVocsnpJHIHFbnzfrV9vdO3sRkVd5Xc3FQ63dsD4VO+7Y5ra EWMw== 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=ld1aOOPFCTaDlIM4pseMTjUT2N/AiXsA3fl7Bo9Xfu4=; b=gpKQPRUUdDjHoF9j/IcsLbj4cLRt9QtlLNwxD9DUD9lb0PLylQO7HbKWkI9EU7IjXt sa1KRGOTa6vIBVesGq/7MM1Z8wjXLM8JrArTr+cFom3oKyvMp8SJ3MiC3tlGVLwCCyg7 7Q4NGxdxcVp1P31g4y3oy/kUs46T3aCHJ1XYjlWmK7Wr2dcyQCV3DlfF/voDSWtmlAM9 8mrY4Fsrf9r+5Lrp+O6yQZNC0t3E7yzPgILsZoTLBuhIFaUumwSNmc2+t673T1ODu/ub X1cSXybRQUf/nR57bwO7SF23zNG+vWhmiE51QoO+BB9P4YBbOzSIcGWis/tLDIiVBjIl FSOQ== X-Gm-Message-State: AOAM53109891gUFMFHibWVwIJCMYTUpS0HAhkxg05gaw/Ms6ygZcu8ZU mMKygnk37S8tLwzOXttl0PVUvOTecbt24w== X-Received: by 2002:a17:90a:a505:: with SMTP id a5mr34071344pjq.58.1619638459021; Wed, 28 Apr 2021 12:34:19 -0700 (PDT) Received: from localhost.localdomain ([71.212.144.24]) by smtp.gmail.com with ESMTPSA id h21sm403725pfo.211.2021.04.28.12.34.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Apr 2021 12:34:18 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 15/15] linux-user/s390x: Handle vector regs in signal stack Date: Wed, 28 Apr 2021 12:34:08 -0700 Message-Id: <20210428193408.233706-16-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210428193408.233706-1-richard.henderson@linaro.org> References: <20210428193408.233706-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1029; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1029.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: thuth@redhat.com, qemu-s390x@nongnu.org, cohuck@redhat.com, laurent@vivier.eu, david@redhat.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- linux-user/s390x/signal.c | 62 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 60 insertions(+), 2 deletions(-) -- 2.25.1 Reviewed-by: David Hildenbrand diff --git a/linux-user/s390x/signal.c b/linux-user/s390x/signal.c index 9d470e4ca0..b537646e60 100644 --- a/linux-user/s390x/signal.c +++ b/linux-user/s390x/signal.c @@ -50,6 +50,12 @@ typedef struct { target_s390_fp_regs fpregs; } target_sigregs; +typedef struct { + uint64_t vxrs_low[16]; + uint64_t vxrs_high[16][2]; + uint8_t reserved[128]; +} target_sigregs_ext; + typedef struct { abi_ulong oldmask[_SIGCONTEXT_NSIG_WORDS]; abi_ulong sregs; @@ -60,15 +66,20 @@ typedef struct { target_sigcontext sc; target_sigregs sregs; int signo; + target_sigregs_ext sregs_ext; uint16_t retcode; } sigframe; +#define TARGET_UC_VXRS 2 + struct target_ucontext { abi_ulong tuc_flags; abi_ulong tuc_link; target_stack_t tuc_stack; target_sigregs tuc_mcontext; - target_sigset_t tuc_sigmask; /* mask last for extensibility */ + target_sigset_t tuc_sigmask; + uint8_t reserved[128 - sizeof(target_sigset_t)]; + target_sigregs_ext tuc_mcontext_ext; }; typedef struct { @@ -128,6 +139,24 @@ static void save_sigregs(CPUS390XState *env, target_sigregs *sregs) } } +static void save_sigregs_ext(CPUS390XState *env, target_sigregs_ext *ext) +{ + int i; + + /* + * if (MACHINE_HAS_VX) ... + * That said, we always allocate the stack storage and the + * space is always available in env. + */ + for (i = 0; i < 16; ++i) { + __put_user(env->vregs[i][1], &ext->vxrs_low[i]); + } + for (i = 0; i < 16; ++i) { + __put_user(env->vregs[i + 16][0], &ext->vxrs_high[i][0]); + __put_user(env->vregs[i + 16][1], &ext->vxrs_high[i][1]); + } +} + void setup_frame(int sig, struct target_sigaction *ka, target_sigset_t *set, CPUS390XState *env) { @@ -161,6 +190,9 @@ void setup_frame(int sig, struct target_sigaction *ka, */ __put_user(sig, &frame->signo); + /* Create sigregs_ext on the signal stack. */ + save_sigregs_ext(env, &frame->sregs_ext); + /* * Set up to return from userspace. * If provided, use a stub already in userspace. @@ -202,6 +234,7 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, rt_sigframe *frame; abi_ulong frame_addr; abi_ulong restorer; + abi_ulong uc_flags; frame_addr = get_sigframe(ka, env, sizeof *frame); trace_user_setup_rt_frame(env, frame_addr); @@ -229,10 +262,15 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, tswap_siginfo(&frame->info, info); /* Create ucontext on the signal stack. */ - __put_user(0, &frame->uc.tuc_flags); + uc_flags = 0; + if (s390_has_feat(S390_FEAT_VECTOR)) { + uc_flags |= TARGET_UC_VXRS; + } + __put_user(uc_flags, &frame->uc.tuc_flags); __put_user(0, &frame->uc.tuc_link); target_save_altstack(&frame->uc.tuc_stack, env); save_sigregs(env, &frame->uc.tuc_mcontext); + save_sigregs_ext(env, &frame->uc.tuc_mcontext_ext); tswap_sigset(&frame->uc.tuc_sigmask, set); /* Set up registers for signal handler */ @@ -271,6 +309,24 @@ static void restore_sigregs(CPUS390XState *env, target_sigregs *sc) } } +static void restore_sigregs_ext(CPUS390XState *env, target_sigregs_ext *ext) +{ + int i; + + /* + * if (MACHINE_HAS_VX) ... + * That said, we always allocate the stack storage and the + * space is always available in env. + */ + for (i = 0; i < 16; ++i) { + __get_user(env->vregs[i][1], &ext->vxrs_low[i]); + } + for (i = 0; i < 16; ++i) { + __get_user(env->vregs[i + 16][0], &ext->vxrs_high[i][0]); + __get_user(env->vregs[i + 16][1], &ext->vxrs_high[i][1]); + } +} + long do_sigreturn(CPUS390XState *env) { sigframe *frame; @@ -292,6 +348,7 @@ long do_sigreturn(CPUS390XState *env) set_sigmask(&set); /* ~_BLOCKABLE? */ restore_sigregs(env, &frame->sregs); + restore_sigregs_ext(env, &frame->sregs_ext); unlock_user_struct(frame, frame_addr, 0); return -TARGET_QEMU_ESIGRETURN; @@ -313,6 +370,7 @@ long do_rt_sigreturn(CPUS390XState *env) set_sigmask(&set); /* ~_BLOCKABLE? */ restore_sigregs(env, &frame->uc.tuc_mcontext); + restore_sigregs_ext(env, &frame->uc.tuc_mcontext_ext); target_restore_altstack(&frame->uc.tuc_stack, env);