From patchwork Wed Apr 28 03:32:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 428586 Delivered-To: patch@linaro.org Received: by 2002:a02:c901:0:0:0:0:0 with SMTP id t1csp222726jao; Tue, 27 Apr 2021 20:32:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyRLXaElmVv3UsYz6pHiI+J4uRlwXbSWn01nL6eZ/ZWeTSsL2T6ObvLAAbxZ3yJbLEH2LD8 X-Received: by 2002:a67:fd86:: with SMTP id k6mr13158917vsq.40.1619580772053; Tue, 27 Apr 2021 20:32:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619580772; cv=none; d=google.com; s=arc-20160816; b=gfoXlF1LgcFy/9OUFstzcZh0g2Nz/wr/j2HHTSb5vSa3QBQv7EgfuS6kC/lAoEbfbH 3/Vk95mNzHezeZiPuHX/PqY210IvseGlyWfDfpI6vW0Q+0LGiyAHDHWo7tW4pPclHh9/ 8+uoVFsinNNPetDCJlWkax+Fxx9KzglFOBsKT87Xa8MgdEpSwSay/wHrv/hKvrBfu5Ey uam8LCifmWxZnR1ZTrnLM2tLjkbxgNhY1QhY3Zb6UJGM2+XMSD5KVIi/v9V3/+nblbxO LSHFNtNI57eVae+d8qiTt+dFmTKGLRAhKcIaN2ulGGCwJP7qon0whnWBM1KXJE59Te4P 4QYw== 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=UK1YbqqlmWYWZ3nCDAZqXJgWrK622W4kr3AfSUK6QPg=; b=Yt4POImtegqWxruxCORErR0SdeCFWw7AgEjFXdkNKViwjWoxFIX366J0grt+k4V6LU 7Gq/UGPOYqVYn+vw70Xk+PUAFOgHJ3fYWF7qdv82iUPt+eERzIlSC+J7HoCsOhWjczfi sGfBPITYAK4EaiUU6GpizJ+rf26XQ2k3uESnix2rNHhjHxEd4e+uNH4ozaCsbz3F353U fYVxmEtHaTO/D90Cjl5VQn2TDMd3k9lrHhEF2FdkEEYZXmd/4IrH5gTp71I5sOfILd8o U6jkKtvxVaYv+hbdKdxNNhTHSf3y7mUEJOhmu8DAAoW4JuDho5xR4itUzOa7qKoD1ZAy DIsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=fcFoqTBj; 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 t21si1448972uaq.69.2021.04.27.20.32.51 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 27 Apr 2021 20:32:52 -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=fcFoqTBj; 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]:44216 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lbawV-0008Az-En for patch@linaro.org; Tue, 27 Apr 2021 23:32:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52590) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lbaw4-000858-P0 for qemu-devel@nongnu.org; Tue, 27 Apr 2021 23:32:26 -0400 Received: from mail-pj1-x1029.google.com ([2607:f8b0:4864:20::1029]:44973) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lbaw1-00008y-QF for qemu-devel@nongnu.org; Tue, 27 Apr 2021 23:32:24 -0400 Received: by mail-pj1-x1029.google.com with SMTP id m6-20020a17090a8586b02901507e1acf0fso8361027pjn.3 for ; Tue, 27 Apr 2021 20:32:21 -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=UK1YbqqlmWYWZ3nCDAZqXJgWrK622W4kr3AfSUK6QPg=; b=fcFoqTBjCqcj/0QvoQKQBtF/pBlujHhlzsVqEmlvQNSRyO2OnpnrgUkBrgLEyz5uhv ZitYcppbUHDNACe3rU7NIy7fBz9zSK6bEGSwl9VMcke8N5KbQ69H/cMyGA5hXp197k0y G7oSLQEBvxVVSqI3zNQO4fhoCjO+E2Xk6dk5tNo4aekxhK7uEgzzWQoT6srTGEb6VdYF 4BbOlK17g6yvE0xlQAqQDrLqf7v7ejSLsKrBFcNvYSc2XFowaC9uZq/e965KKp2Vs487 gr+P6uMwYv1/9YfMSEJLc1d/6o1JYnhDNwUETYjegcxSIlnUkA2W57TWYOjHpnotSrUx Viug== 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=UK1YbqqlmWYWZ3nCDAZqXJgWrK622W4kr3AfSUK6QPg=; b=tAX4GmDd8Ri5p6Q+XPI5HustC3BWeETyhVboG84XtBfW/Or0ia9WCRNNs6j4UNlqfL sDqMyrF+K6lJAdtt4BPDJFKSBEbrKzjYItDfkMx9SdtcfJUztmStHsd6oWoBHhCg3rpQ UmwsYQ4EVEN+fpzFPa19bWJfw3z7hlqK0WnYX81LJ0lQxHoDeT9fXzjzrnfvKvP+SkVN qJ846nLsu/itGFbmTN0HRVWI1xnVdR9E9SQlC6S0ZPK8uqT+kXJYrFf0bXL/1UZc54df mbF9cQHkj/wbStvvTMCxwT006M9X/scjewwnOf42UTzv0AIY07XFmQabe8dnXcuks4F4 A02Q== X-Gm-Message-State: AOAM530LXd/JzO5yJurhezPQawdsSQcCKKRYOJLeNfTbqmfm7m2rc0sF +LrJUPg/ayhLYjgYvXeMn64kzNime4wFdg== X-Received: by 2002:a17:902:7b8e:b029:ec:982d:7a7e with SMTP id w14-20020a1709027b8eb02900ec982d7a7emr27912209pll.55.1619580740428; Tue, 27 Apr 2021 20:32:20 -0700 (PDT) Received: from localhost.localdomain ([71.212.144.24]) by smtp.gmail.com with ESMTPSA id 18sm3572335pji.30.2021.04.27.20.32.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Apr 2021 20:32:20 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 3/3] linux-user/s390x: Handle vector regs in signal stack Date: Tue, 27 Apr 2021 20:32:04 -0700 Message-Id: <20210428033204.133471-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210428033204.133471-1-richard.henderson@linaro.org> References: <20210428033204.133471-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 diff --git a/linux-user/s390x/signal.c b/linux-user/s390x/signal.c index fb7065f243..57752a2a96 100644 --- a/linux-user/s390x/signal.c +++ b/linux-user/s390x/signal.c @@ -51,6 +51,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; @@ -61,15 +67,20 @@ typedef struct { target_sigcontext sc; target_sigregs sregs; int signo; + target_sigregs_ext sregs_ext; uint8_t retcode[S390_SYSCALL_SIZE]; } 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 { @@ -129,6 +140,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) { @@ -156,6 +185,9 @@ void setup_frame(int sig, struct target_sigaction *ka, /* Place signal number on stack to allow backtrace from handler. */ __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. @@ -196,6 +228,7 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, { rt_sigframe *frame; abi_ulong frame_addr; + abi_ulong uc_flags; frame_addr = get_sigframe(ka, env, sizeof *frame); trace_user_setup_rt_frame(env, frame_addr); @@ -223,10 +256,15 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, tswap_siginfo(&frame->info, info); /* Create the ucontext. */ - __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 */ @@ -265,6 +303,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; @@ -286,6 +342,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; @@ -308,6 +365,7 @@ long do_rt_sigreturn(CPUS390XState *env) target_restore_altstack(&frame->uc.tuc_stack, env); restore_sigregs(env, &frame->uc.tuc_mcontext); + restore_sigregs_ext(env, &frame->uc.tuc_mcontext_ext); unlock_user_struct(frame, frame_addr, 0); return -TARGET_QEMU_ESIGRETURN;