From patchwork Wed May 22 03:44:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 798141 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:92:b0:351:d90a:5487 with SMTP id m18csp276941wrx; Tue, 21 May 2024 20:45:11 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXKMvcidJ2TBm36voP8HDtW7ju6U44bM3bPotjSTcnWN7ia2KrgP8qkSXW510I0TAXH/+slkIJ6lUKTpW7rWAPy X-Google-Smtp-Source: AGHT+IH2ordhD7XcSxkKJgjY6FzFi4tTyXaw3OiFkY2nh8BxrVGuVUv0XdVO4xvTaPJRLPNyvl7B X-Received: by 2002:a05:620a:25d0:b0:792:faec:3e2e with SMTP id af79cd13be357-794994ceb16mr88317085a.75.1716349510912; Tue, 21 May 2024 20:45:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1716349510; cv=none; d=google.com; s=arc-20160816; b=V3X/3m/KRj1bTbAASXf3HGGZihkP9Z/V3sweX1XUiLzRjIZJ/PExOmv1iJbRknb6AG +C8peTa4B1IGIBEP1bQMkJwka0XH8iM6RlBNYMJNdu1mHC6AUKSgXbNopKuzhXw5cRvB dRr+7UfoW84IJb7KAgYzf297S1M28IR7JN/om32XbmfKjRiq8r/B43BQAjbcGxgkFoUm NCv50fQFljdznSkjiWpYRlJ3u0/Rye0lfat2vGKsG6IFFZElRwZU581tCHGDKcv8o1a+ 6Z07Oy4ZTLThBAaabgmS51OkPzMkdjUcshR1eobYZSnzluWZWtnE4WrSI7KmNkNeoe4k C2Qw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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:cc:to :from:dkim-signature; bh=ClmjZOy3QQNiKciKtrEnKHv+DzIwPzBDEJYBBNDBr+E=; fh=aRZTpPWhHXk/ANUEh7k3oMs8V5C8zTe7pkcDFIBzjKg=; b=v1q4mQc7rc7bTGGY80xFvcErMzYcULOcVC6HxVDYxiUhL4zZP+sFI9uGjOrbH5deGE Y9mxCl711BH0VW9evAenCPlv65MooAbnqCApyUdeNSb2Du0h6JEe38B1gE+VNtilTPal QeU3pJI6ohCu95GnalcxKEQbSbmZojH0bZxZBx93BNnl8ZcPRFViKbZh7BzkFbJnj8J7 won363dCxWv4I3oIwDaNiI8jYti+yj8TaK8cDpLKJwGeFpeI4L6h0TuBM6W7x55r6Nl6 o9/9xXNqbdfOYTWSwlWMF7sMOX2opzG+Ete2cn55IHF+FOTrBHG4S9aLNAwELHLyS7qG S3uA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EaseiIvl; 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=pass (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 af79cd13be357-792bf38c188si711635585a.703.2024.05.21.20.45.10 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 21 May 2024 20:45:10 -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=pass header.i=@linaro.org header.s=google header.b=EaseiIvl; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s9cuI-0003RE-BZ; Tue, 21 May 2024 23:44:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s9cuH-0003R1-Da for qemu-devel@nongnu.org; Tue, 21 May 2024 23:44:49 -0400 Received: from mail-ot1-x336.google.com ([2607:f8b0:4864:20::336]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s9cuE-00049z-Or for qemu-devel@nongnu.org; Tue, 21 May 2024 23:44:49 -0400 Received: by mail-ot1-x336.google.com with SMTP id 46e09a7af769-6f1242f1dcdso2651313a34.3 for ; Tue, 21 May 2024 20:44:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1716349484; x=1716954284; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ClmjZOy3QQNiKciKtrEnKHv+DzIwPzBDEJYBBNDBr+E=; b=EaseiIvlNAgFLx9w/lZSWwTK7QD1NDoEm43To1yrYMKdOf4Pm0heydnuY8FABHz3XZ PnR+o7PlSX1F/XFdPhMnAHoSeQpu21xeStYmVWrR4XOHvJ0+wrqE963S3S3k7bnLUTny ppd5GAGw613gQ/AvG9g5x4fzKH3OqffIvovgKGmRWhUU1UekBBG9UtlUZYVON+zqQNRl rUfR+NsDVmOpEBd8c0uu66+HzwJa1ulrV4fllxvoPxb0NHlnkL813fKvKm59XSd4v53n fvNXfy2k9qqiJ3gvjgkz+UTgbcwhALF/8BzgDZvvBVSZBziagO1YeJpYA500mo+IcjF2 1hjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716349484; x=1716954284; 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:message-id:reply-to; bh=ClmjZOy3QQNiKciKtrEnKHv+DzIwPzBDEJYBBNDBr+E=; b=uYR+VFMCGFAWmxCV0ZMHC6ZzMp/lpkutKxATGc3oxZK27wwp684HaRbs6qv0MQYvjY Cb6mZLgkTdgBhnAgY3gJSdL3ot2R3lHkVDmbURz74i/HkCe/8Ks48/Kdt2dHMZaaUf3d G25Af8yhc+HrJS/QzYq6A55FDNzcaUIQMQ0GCvtCJ4l5iILh0oJnXG5oyO6ugUzGKmiR +zxBfDq4HoMFQU8KWm2ipQBQ5WyDnp1UEGTHbD4Rqb+g8LMwS0dPw+NwwY5hI9Nyystu Vj8EdnSvDDQXTPrxOKdOHCVT+wkSI26FWvPw9kbiuwmTIOAerL5tlsplyvoFJrmv0kA5 XOIg== X-Gm-Message-State: AOJu0YxHDYAinTDS27Q0DZft1V2Fh90u5J0LxTBibMFaFdS/DtXxiOX+ P1fShcOIq4e+aEERSfZW3cvRhjdBFPB7CYpHBQUEQoXAGwRlj/kHFp9l4Q0p8AnfSALU/D86l8U t X-Received: by 2002:a05:6870:59d:b0:221:1c2f:23ee with SMTP id 586e51a60fabf-24c68b5de72mr976548fac.22.1716349484414; Tue, 21 May 2024 20:44:44 -0700 (PDT) Received: from stoup.. (174-21-72-5.tukw.qwest.net. [174.21.72.5]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-6f4d2af2bafsm21416617b3a.162.2024.05.21.20.44.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 May 2024 20:44:43 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, mark.cave-ayland@ilande.co.uk Subject: [PATCH RISU v2 1/8] risu: Allow use of ELF test files Date: Tue, 21 May 2024 20:44:35 -0700 Message-Id: <20240522034442.140293-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240522034442.140293-1-richard.henderson@linaro.org> References: <20240522034442.140293-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::336; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x336.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=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org By using elf files, we make it easier to disassemble the test file, to match comparison failures to code. Signed-off-by: Richard Henderson --- risu.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 52 insertions(+), 5 deletions(-) diff --git a/risu.c b/risu.c index c28b4a5..c9c3a38 100644 --- a/risu.c +++ b/risu.c @@ -24,6 +24,15 @@ #include #include #include +#include + +/* TODO: Improve configure. */ +#ifdef __linux__ +#include +#define HOST_BIG_ENDIAN (__BYTE_ORDER == __BIG_ENDIAN) +#else +#error Need HOST_BIG_ENDIAN +#endif #include "config.h" #include "risu.h" @@ -346,8 +355,11 @@ static void load_image(const char *imgfile) { /* Load image file into memory as executable */ struct stat st; + void *addr; + int fd; + fprintf(stderr, "loading test image %s...\n", imgfile); - int fd = open(imgfile, O_RDONLY); + fd = open(imgfile, O_RDONLY); if (fd < 0) { fprintf(stderr, "failed to open image file %s\n", imgfile); exit(EXIT_FAILURE); @@ -356,20 +368,55 @@ static void load_image(const char *imgfile) perror("fstat"); exit(EXIT_FAILURE); } - size_t len = st.st_size; - void *addr; /* Map writable because we include the memory area for store * testing in the image. */ - addr = mmap(0, len, PROT_READ | PROT_WRITE | PROT_EXEC, + addr = mmap(0, st.st_size, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE, fd, 0); if (addr == MAP_FAILED) { perror("mmap"); exit(EXIT_FAILURE); } close(fd); - image_start = addr; + + if (memcmp(addr, ELFMAG, SELFMAG) == 0) { + union { + unsigned char ident[EI_NIDENT]; + Elf32_Ehdr h32; + Elf64_Ehdr h64; + } *e = addr; + size_t entry; + + /* + * TODO: More complete parsing of ELF file, verify assumtion, namely: + * Single PT_LOAD covering the ELF header, code and data. + * For now, simply update image_start from the elf header. + */ + if (e->ident[EI_DATA] != + (HOST_BIG_ENDIAN ? ELFDATA2MSB : ELFDATA2LSB)) { + fprintf(stderr, "%s: Endian mismatch: EI_DATA = %x\n", + imgfile, e->ident[EI_DATA]); + exit(1); + } + + switch (e->ident[EI_CLASS]) { + case ELFCLASS32: + entry = e->h32.e_entry; + break; + case ELFCLASS64: + entry = e->h64.e_entry; + break; + default: + fprintf(stderr, "%s: Bad elf header: EI_CLASS = %x\n", + imgfile, e->ident[EI_CLASS]); + exit(1); + } + image_start = addr + entry; + } else { + /* Raw binary image. */ + image_start = addr; + } image_start_address = (uintptr_t) addr; } From patchwork Wed May 22 03:44:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 798146 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:92:b0:351:d90a:5487 with SMTP id m18csp277120wrx; Tue, 21 May 2024 20:45:52 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUoboS55WzAyVZsPDqjCbyIRJe+XIO5qTxGrZ9xxAFbMa8V8vwbB84VWan2XrQ11Lpmyene1kFCOdZNOzpc8VS3 X-Google-Smtp-Source: AGHT+IGXvQwOrwd179eJREmgxfdJY48q/HzxlXzr5pT9bsI1DBUzFAws9BleWULgLYOAbfsU7YhL X-Received: by 2002:ac8:7f4e:0:b0:43a:b2c9:60de with SMTP id d75a77b69052e-43f9e1b3560mr13091581cf.56.1716349552014; Tue, 21 May 2024 20:45:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1716349551; cv=none; d=google.com; s=arc-20160816; b=H9eHzK2PWYb0bdMWv7kVzeFGANSt3l7d/XAbYmr/A0eofu4j+NU9dYE7cyQ3KRs6dW 4NpZahabDjPOidSEk3T7m22gjVCd2wB1xsktoYebzLPr4xILtRkvjfRdzsId2BrDJhDG 4rgYhE5O55CFb9fbMM4SbM6gPICdwf+1TePYJ+KYe8r9fw7MLczf8LbnpsCQax9y2tT+ AKfKbRbSOcEcxe7ChiAlO00nQzbKNHbUlzeGE+RAQewuQhTvmt6mWmoNH72kTZxwwxpI BS9WOWS6VvvZWVKu7j029aDiQygi2rgbh08sm7kl6OJseKxs1MY9IsfODnEGBuLp17KC EjpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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:cc:to :from:dkim-signature; bh=lJ/MHrlbj4C0ri8M58dDIQBRERSolyRdsK7MrfghSiM=; fh=Pyx0JcnHOfsBdHnnRoKryXfdQ8v+s1Cx+4MBp+daf3o=; b=jvZTiMslfajjAG20gIHA3aNkVb5XcnhZk5XGjiKPnrXgBZyaKh3WStAhHtod5WaNtq vARFvLZOoMeyNlNAXCUWaorc9PsW47v1NsF51+ADEhF9v4lCEjpiUI76X+blqwOQAQbo cpQMDEJaCRIEB+kDzk1Kf1VbT7FT61U/cUTa3ANK68miMoTZzSSxbtZ0OX1bB8bzi4JG vVLETikoUXiKeNt60oJJuMDEYfdCGfc7cDe2RZxDTg/bE82mMLiAp5M0/CN9AJa5AV7m ypGMX0BY/+sTEwUBSwqbChe02xFeLzL9xQ6TozQ8N4MBKqD4N5dj3kv4SL85/3Uit9FX sKFA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EnSpFhiy; 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=pass (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 d75a77b69052e-43df8f159ecsi284916351cf.229.2024.05.21.20.45.51 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 21 May 2024 20:45:51 -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=pass header.i=@linaro.org header.s=google header.b=EnSpFhiy; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s9cuK-0003S8-Ad; Tue, 21 May 2024 23:44:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s9cuJ-0003RQ-1P for qemu-devel@nongnu.org; Tue, 21 May 2024 23:44:51 -0400 Received: from mail-oa1-x35.google.com ([2001:4860:4864:20::35]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s9cuF-0004A4-PR for qemu-devel@nongnu.org; Tue, 21 May 2024 23:44:50 -0400 Received: by mail-oa1-x35.google.com with SMTP id 586e51a60fabf-244bdd730dcso2063728fac.0 for ; Tue, 21 May 2024 20:44:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1716349485; x=1716954285; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=lJ/MHrlbj4C0ri8M58dDIQBRERSolyRdsK7MrfghSiM=; b=EnSpFhiycxi0N+874U70eKBtYzm40R7Q0zr7Rcre1+PSkFNpAYpJXpjBJKffWNrqp+ PeSEFmGfAw4i+0ww0vDy/B4VDuOoVdc3Ntwfvxq7fqNhnZdoOAEkUS7wxSgNUaimwemh 8S/zl9YQKJiptT3In5Rub/DWme3p9NZzabj4SD/q2J4rwh0wRdkXf9YdxVMFse/PiIyt 13zp3N9VKx723UUP/ooqasg3Y02nVFNDmYb6/QThuqkKhc2cGu9vnXNRptPdbUud7usu iyEWQv/CQqaBqn1mT1584Pnn3zpKFulZ/Z5vPzDYftDn5BqjgJ8aEF7e0LbZs/p8oqPH KrDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716349485; x=1716954285; 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:message-id:reply-to; bh=lJ/MHrlbj4C0ri8M58dDIQBRERSolyRdsK7MrfghSiM=; b=D73uISaU1/rvsMqXEU5pcf7oBx7RsIXgrdP+Ism4Ia30JSreGMUVCKk9Uro8mbr6cg bLORyYij1nslc8D3gk1tFsva9ZG3BOzu2iA/cILB07d6TcBEHmt1aFg9u4VWizsQ40Q7 5pSicFpBY8Rhq05UoN/S6hlVm2+2W+08P0lbMaP0poV6tUVBlUfhoV1IPfpQO4wZvoCa CPv5s7RodMD5mLPqEjthUiZR0l2CaESL2r/aa3yuCsoXDVd8TdBToIccsjYIxWX97xiA dQTI0nSj/9DY1ZEMiF/psvIz9qrOZhRG9L3PgMvxpYDa+zG5WlbbuMAxn4mixbfTZTQt AUag== X-Gm-Message-State: AOJu0YzL5oPg/TCXuOrmFqxOyUnMp6Mcg0X+BPgbvuq6FAr9fI86KPIC WUY5FKYBHgwolQRPtv1jgYEFqP3doUG3moW7yUZNtC2IwrKAQNtYSYZKLHG5CSDhoQhn8MSxhvw B X-Received: by 2002:a05:6870:9627:b0:23c:1f34:730 with SMTP id 586e51a60fabf-24c690dcbeamr1066614fac.49.1716349485353; Tue, 21 May 2024 20:44:45 -0700 (PDT) Received: from stoup.. (174-21-72-5.tukw.qwest.net. [174.21.72.5]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-6f4d2af2bafsm21416617b3a.162.2024.05.21.20.44.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 May 2024 20:44:44 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, mark.cave-ayland@ilande.co.uk, =?utf-8?q?Phili?= =?utf-8?q?ppe_Mathieu-Daud=C3=A9?= Subject: [PATCH RISU v2 2/8] Build elf test cases instead of raw binaries Date: Tue, 21 May 2024 20:44:36 -0700 Message-Id: <20240522034442.140293-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240522034442.140293-1-richard.henderson@linaro.org> References: <20240522034442.140293-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2001:4860:4864:20::35; envelope-from=richard.henderson@linaro.org; helo=mail-oa1-x35.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=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org For test_arch64.s and test_arm.s, use '.inst' so that the risu control insns are marked as instructions for disassembly. For test_i386.S, split the data to be loaded into the data section; fix an error aligning the data: 16 not 2**16. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- Makefile | 19 ++++++++++--------- test.ld | 12 ++++++++++++ test_aarch64.s | 4 ++-- test_arm.s | 16 +++++++++++----- test_i386.S | 4 +++- 5 files changed, 38 insertions(+), 17 deletions(-) create mode 100644 test.ld diff --git a/Makefile b/Makefile index ad7f879..2bd08aa 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,8 @@ ALL_CFLAGS = -Wall -D_GNU_SOURCE -DARCH=$(ARCH) -U$(ARCH) $(BUILD_INC) $(CFLAGS) PROG=risu SRCS=risu.c comms.c risu_$(ARCH).c risu_reginfo_$(ARCH).c HDRS=risu.h risu_reginfo_$(ARCH).h -BINS=test_$(ARCH).bin +BINO=test_$(ARCH).o +BINE=test_$(ARCH).elf # For dumping test patterns RISU_BINS=$(wildcard *.risu.bin) @@ -30,7 +31,7 @@ RISU_ASMS=$(patsubst %.bin,%.asm,$(RISU_BINS)) OBJS=$(SRCS:.c=.o) -all: $(PROG) $(BINS) +all: $(PROG) $(BINE) dump: $(RISU_ASMS) @@ -43,17 +44,17 @@ $(PROG): $(OBJS) %.o: %.c $(HDRS) $(CC) $(CPPFLAGS) $(ALL_CFLAGS) -o $@ -c $< -%_$(ARCH).bin: %_$(ARCH).elf - $(OBJCOPY) -O binary $< $@ +%_$(ARCH).o: %_$(ARCH).s + $(CC) -o $@ -c $< -%_$(ARCH).elf: %_$(ARCH).s - $(AS) -o $@ $< - -%_$(ARCH).elf: %_$(ARCH).S +%_$(ARCH).o: %_$(ARCH).S $(CC) $(CPPFLAGS) -o $@ -c $< +%_$(ARCH).elf: test.ld %_$(ARCH).o + $(LD) -o $@ -T $^ + clean: - rm -f $(PROG) $(OBJS) $(BINS) + rm -f $(PROG) $(OBJS) $(BINO) $(BINE) distclean: clean rm -f config.h Makefile.in diff --git a/test.ld b/test.ld new file mode 100644 index 0000000..eb0a76a --- /dev/null +++ b/test.ld @@ -0,0 +1,12 @@ +ENTRY(start) + +PHDRS { + text PT_LOAD FILEHDR PHDRS; +} + +SECTIONS { + . = SIZEOF_HEADERS; + PROVIDE(start = .); + .text : { *(.text) } :text + .data : { *(.data) } :text +} diff --git a/test_aarch64.s b/test_aarch64.s index f75d588..88902c6 100644 --- a/test_aarch64.s +++ b/test_aarch64.s @@ -80,6 +80,6 @@ fmov d31, #31.0 /* do compare. * The manual says instr with bits (28,27) == 0 0 are UNALLOCATED */ -.int 0x00005af0 +.inst 0x00005af0 /* exit test */ -.int 0x00005af1 +.inst 0x00005af1 diff --git a/test_arm.s b/test_arm.s index 49552f2..62582e7 100644 --- a/test_arm.s +++ b/test_arm.s @@ -9,20 +9,26 @@ * Peter Maydell (Linaro) - initial implementation *******************************************************************************/ +.text + /* magic instruction to force ARM mode whether we were in ARM or Thumb before */ -.int 0xe0004778 +.inst 0xe0004778 + /* Initialise the gp regs */ add r0, pc, #4 ldmia r0, {r0,r1,r2,r3,r4,r5,r6,r7,r8,r9,r10,r11,r12,r14} -b next +b 1f + .int 0,1,2,3,4,5,6,7,8,9,10,11,12,14 -next: + +1: msr CPSR_fs, #0 + /* do compare. * The space 0xE7F___F_ is guaranteed to always UNDEF * and not to be allocated for insns in future architecture * revisions. */ -.int 0xe7fe5af0 +.inst 0xe7fe5af0 /* exit test */ -.int 0xe7fe5af1 +.inst 0xe7fe5af1 diff --git a/test_i386.S b/test_i386.S index 05344d7..2e2b090 100644 --- a/test_i386.S +++ b/test_i386.S @@ -13,6 +13,7 @@ /* Initialise the registers to avoid spurious mismatches */ +.text #ifdef __x86_64__ #define BASE %rax lea 2f(%rip), BASE @@ -71,7 +72,8 @@ /* exit test */ ud1 %ecx, %eax - .p2align 16 +.data + .balign 16 2: .set i, 0 .rept 256 From patchwork Wed May 22 03:44:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 798149 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:92:b0:351:d90a:5487 with SMTP id m18csp277218wrx; Tue, 21 May 2024 20:46:21 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVKTRem296p+f6KARyvx519YaNLWkdtn4CydvFJZ9ze7i+/ExKpOO42zPRCLPguSgvLfrbM5aCrsprdrmPvZkqD X-Google-Smtp-Source: AGHT+IG1mnG6BzXpSPQjwAyVeQCh3RmB/9HYYNkBhM0eFx13vYmIstRIMuUPumo3oURHUEY8okSQ X-Received: by 2002:ae9:e502:0:b0:790:979b:c20c with SMTP id af79cd13be357-7949941ccafmr80511285a.12.1716349580945; Tue, 21 May 2024 20:46:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1716349580; cv=none; d=google.com; s=arc-20160816; b=LxQQucu25BevM3vkDI5RPZZ9/XizfyIhyjRh/utbpDJcnTHCUvuoEC18fQtXmFyGor WuwFKYM2hS6i2V/ZrwaCerJKfsUes4jOL9ralK3S6S7VVoxCIS3FgVp6wkQiEAlBSo5Y NFb/jaJnLFstNlk8Z1vZPCrlDFSdy5ZZI/Uw1MQCajxBB4UqekEimiFxhRAtGPJb8E2i UxqlXyUM8dE2t8GZvBpeOEaFNL22ogu13gbU/nQHAqgMtRy/FGIx5CE40DIPVdl8AlAM HTIuEfruf2Jc92xov4wjd1J+s6K55faweXEU01oPWWOzSfyiNKJgsA0IagAwukwt+F3n crkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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:cc:to :from:dkim-signature; bh=x2wkzB9GtMTSuOUWMWtp1POxPGIbKlhGRu9DTuWffok=; fh=aRZTpPWhHXk/ANUEh7k3oMs8V5C8zTe7pkcDFIBzjKg=; b=StBEZkkjv63diJtb3vBmds3KPO+ckXdRM2FmMZtx/WYc7gwwbIEEnm6z/PfTlUgq1g /671fQtdjzZST4CNbcXy+G/2pPsdIfkaDMV4mBgWaoMTbUhhkyiKrE8DyjNGfFOIoe7o A9wGzTwxntKt/lWDXCTSVdB7ifPpt9ThGYtv3y4r15Ttr0V8/aadR+D+LT0NK6C4znUJ IjK7BNnjn/Cmy0pL6bgIrUzxSNJnE/lzq+kwjpQMqjD+KZ6m2XeQoABmIBi0tb2mL8Ub Ova0czo+gVdhahek+OH6m0W4e/J4HQqhnHy1khDvRPM2eONAtynFmSRdGQhtkDtmY99V x9MQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="vqEI/6eK"; 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=pass (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 af79cd13be357-792bf366267si359432785a.597.2024.05.21.20.46.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 21 May 2024 20:46:20 -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=pass header.i=@linaro.org header.s=google header.b="vqEI/6eK"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s9cuN-0003Ul-F2; Tue, 21 May 2024 23:44:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s9cuK-0003SE-BP for qemu-devel@nongnu.org; Tue, 21 May 2024 23:44:52 -0400 Received: from mail-oa1-x33.google.com ([2001:4860:4864:20::33]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s9cuG-0004A9-HR for qemu-devel@nongnu.org; Tue, 21 May 2024 23:44:51 -0400 Received: by mail-oa1-x33.google.com with SMTP id 586e51a60fabf-2454154e53aso2686439fac.3 for ; Tue, 21 May 2024 20:44:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1716349486; x=1716954286; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=x2wkzB9GtMTSuOUWMWtp1POxPGIbKlhGRu9DTuWffok=; b=vqEI/6eKfaAgF8Y7s1meh36GtgXDYyuGZckgDpsP23B12BaoWWt7lc6u5NjKMI8L+O SDLGbVLB2dCvRr8A7wz0ADH0JTI/IytlGFeuv3KFo/RZqwWYC80KgLU4wMr7zBUdU545 0t83BOmh90sU2L8+OCCQHg+HblsLYl21yBMzT6cZDq8E2rgOkKlTzcJknHL4gRmJDXhP bm8/aDVtUHi+Q++N2KnmMdM6YH21N2as7TYhx+wuoOcRUchuXFpI5eb2AxvkgPN7ilJe sRmNC2jNQ443p/SuHfBVuYRQViletmNTAOVkg3XNn/bOyI2Fxsb2ly3CnzXdGTqxX7fe 4e9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716349486; x=1716954286; 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:message-id:reply-to; bh=x2wkzB9GtMTSuOUWMWtp1POxPGIbKlhGRu9DTuWffok=; b=v85zYGsSfIKcMkzIk0Mkj3AisRnyWGz2KaiuQ768T5uJn6oOOGdFcCWCuLUYHGWXAc MGn2C58w0S4V6hMo/SjqyxR0L+7EXElKa794hc0uHvDiNiGQYnNr+EcZnJKtJk+drSuT KIZkZwgnika4gIou5a2RKI9QTq7ADaLoUB6ZnzTkyOvTLef0QPpkpQe8BqPNoUXm7XTO F9Aqlh0JTYgp4vXgzhsSH/3MumWuOc48z6ZQ97bRtpn2ysQlwpcclCLwh48DnMcCnEbX z235uWeJfNiXAouwrfCKk4IX2lC5A1/1kO+Ra0Uk6T5sw9LARZ7m+yaDr2wLnFmzDv6r k9pg== X-Gm-Message-State: AOJu0YxTlypEpunAwVxA+uckwvyHW9QGGMgxlsE3vUe6YfcIea3iHe48 gZ7hHj36jtrDnGvKCvIhx/LarJm0NK2U0TdCs/1rbZKTNdW86Kzp5ZNKWXgvZ9PfzzF0ZjHltyd B X-Received: by 2002:a05:6870:eca5:b0:23f:ba88:d5ac with SMTP id 586e51a60fabf-24c68d77dbfmr1026573fac.53.1716349486280; Tue, 21 May 2024 20:44:46 -0700 (PDT) Received: from stoup.. (174-21-72-5.tukw.qwest.net. [174.21.72.5]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-6f4d2af2bafsm21416617b3a.162.2024.05.21.20.44.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 May 2024 20:44:45 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, mark.cave-ayland@ilande.co.uk Subject: [PATCH RISU v2 3/8] Introduce host_context_t Date: Tue, 21 May 2024 20:44:37 -0700 Message-Id: <20240522034442.140293-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240522034442.140293-1-richard.henderson@linaro.org> References: <20240522034442.140293-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2001:4860:4864:20::33; envelope-from=richard.henderson@linaro.org; helo=mail-oa1-x33.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=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Most hosts pass ucontext_t as the third parameter of signal handlers. In one existing usage, loongarch64 is using the kernel's struct ucontext instead of libc's ucontext_t. This is probably a simple mistake that could be fixed, but the structure member names differ, so the change would not be completely mechanical. However, due to a sequence of historical mistakes, sparc64 linux does not pass any kind of ucontext_t to the signal handler, but uses struct sigcontext instead. Prepare for that by adding a new indirection typedef. This allows us to clean up existing usage with void*. Signed-off-by: Richard Henderson --- risu.h | 16 ++++++++-------- risu_reginfo_aarch64.h | 2 ++ risu_reginfo_arm.h | 2 ++ risu_reginfo_i386.h | 2 ++ risu_reginfo_loongarch64.h | 3 +++ risu_reginfo_m68k.h | 2 ++ risu_reginfo_ppc64.h | 2 ++ risu_reginfo_s390x.h | 2 ++ risu_aarch64.c | 6 ++---- risu_arm.c | 7 ++----- risu_i386.c | 7 ++----- risu_loongarch64.c | 6 ++---- risu_m68k.c | 6 ++---- risu_ppc64.c | 6 ++---- risu_reginfo_loongarch64.c | 3 +-- risu_s390x.c | 5 ++--- 16 files changed, 38 insertions(+), 39 deletions(-) diff --git a/risu.h b/risu.h index 4203178..0ac7d1e 100644 --- a/risu.h +++ b/risu.h @@ -68,7 +68,7 @@ typedef enum { /* This is the data structure we pass over the socket for OP_COMPARE * and OP_TESTEND. It is a simplified and reduced subset of what can - * be obtained with a ucontext_t*, and is architecture specific + * be obtained with a ucontext_t, and is architecture specific * (defined in risu_reginfo_*.h). */ struct reginfo; @@ -93,14 +93,14 @@ void send_response_byte(int sock, int resp); /* Interface provided by CPU-specific code: */ -/* Move the PC past this faulting insn by adjusting ucontext. */ -void advance_pc(void *uc); +/* Move the PC past this faulting insn by adjusting signal context. */ +void advance_pc(host_context_t *hc); -/* Set the parameter register in a ucontext_t to the specified value. +/* + * Set the parameter register in a host_context_t to the specified value. * (32-bit targets can ignore high 32 bits.) - * vuc is a ucontext_t* cast to void*. */ -void set_ucontext_paramreg(void *vuc, uint64_t value); +void set_ucontext_paramreg(host_context_t *hc, uint64_t value); /* Return the value of the parameter register from a reginfo. */ uint64_t get_reginfo_paramreg(struct reginfo *ri); @@ -114,8 +114,8 @@ RisuOp get_risuop(struct reginfo *ri); /* Return the PC from a reginfo */ uintptr_t get_pc(struct reginfo *ri); -/* initialize structure from a ucontext */ -void reginfo_init(struct reginfo *ri, ucontext_t *uc, void *siaddr); +/* initialize structure from a host_context_t. */ +void reginfo_init(struct reginfo *ri, host_context_t *hc, void *siaddr); /* return true if structs are equal, false otherwise. */ bool reginfo_is_eq(struct reginfo *r1, struct reginfo *r2); diff --git a/risu_reginfo_aarch64.h b/risu_reginfo_aarch64.h index 097b7ad..bc3a661 100644 --- a/risu_reginfo_aarch64.h +++ b/risu_reginfo_aarch64.h @@ -15,6 +15,8 @@ #include +typedef ucontext_t host_context_t; + /* The kernel headers set this based on future arch extensions. The current arch maximum is 16. Save space below. */ #undef SVE_VQ_MAX diff --git a/risu_reginfo_arm.h b/risu_reginfo_arm.h index 60754a9..1937e46 100644 --- a/risu_reginfo_arm.h +++ b/risu_reginfo_arm.h @@ -13,6 +13,8 @@ #ifndef RISU_REGINFO_ARM_H #define RISU_REGINFO_ARM_H +typedef ucontext_t host_context_t; + struct reginfo { uint64_t fpregs[32]; uint32_t faulting_insn; diff --git a/risu_reginfo_i386.h b/risu_reginfo_i386.h index b468f79..abbfbe1 100644 --- a/risu_reginfo_i386.h +++ b/risu_reginfo_i386.h @@ -12,6 +12,8 @@ #ifndef RISU_REGINFO_I386_H #define RISU_REGINFO_I386_H +typedef ucontext_t host_context_t; + struct avx512_reg { uint64_t q[8]; }; diff --git a/risu_reginfo_loongarch64.h b/risu_reginfo_loongarch64.h index 892b477..6c85951 100644 --- a/risu_reginfo_loongarch64.h +++ b/risu_reginfo_loongarch64.h @@ -12,6 +12,9 @@ #ifndef RISU_REGINFO_LOONGARCH64_H #define RISU_REGINFO_LOONGARCH64_H +/* From kernel not libc . */ +typedef struct ucontext host_context_t; + struct reginfo { uint64_t regs[32]; uint64_t pc; diff --git a/risu_reginfo_m68k.h b/risu_reginfo_m68k.h index c1c9fe6..233f901 100644 --- a/risu_reginfo_m68k.h +++ b/risu_reginfo_m68k.h @@ -9,6 +9,8 @@ #ifndef RISU_REGINFO_M68K_H #define RISU_REGINFO_M68K_H +typedef ucontext_t host_context_t; + struct reginfo { uint32_t faulting_insn; uint32_t pc; diff --git a/risu_reginfo_ppc64.h b/risu_reginfo_ppc64.h index 4b1d8bd..424fd02 100644 --- a/risu_reginfo_ppc64.h +++ b/risu_reginfo_ppc64.h @@ -14,6 +14,8 @@ #ifndef RISU_REGINFO_PPC64LE_H #define RISU_REGINFO_PPC64LE_H +typedef ucontext_t host_context_t; + struct reginfo { uint32_t faulting_insn; uint32_t prev_insn; diff --git a/risu_reginfo_s390x.h b/risu_reginfo_s390x.h index c65fff7..5126fd5 100644 --- a/risu_reginfo_s390x.h +++ b/risu_reginfo_s390x.h @@ -12,6 +12,8 @@ #ifndef RISU_REGINFO_S390X_H #define RISU_REGINFO_S390X_H +typedef ucontext_t host_context_t; + struct reginfo { uint64_t psw_mask; uint64_t pc_offset; diff --git a/risu_aarch64.c b/risu_aarch64.c index f8a8412..af94539 100644 --- a/risu_aarch64.c +++ b/risu_aarch64.c @@ -12,15 +12,13 @@ #include "risu.h" -void advance_pc(void *vuc) +void advance_pc(ucontext_t *uc) { - ucontext_t *uc = vuc; uc->uc_mcontext.pc += 4; } -void set_ucontext_paramreg(void *vuc, uint64_t value) +void set_ucontext_paramreg(ucontext_t *uc, uint64_t value) { - ucontext_t *uc = vuc; uc->uc_mcontext.regs[0] = value; } diff --git a/risu_arm.c b/risu_arm.c index a20bf73..0e72fba 100644 --- a/risu_arm.c +++ b/risu_arm.c @@ -38,16 +38,13 @@ int insnsize(ucontext_t *uc) return 4; } -void advance_pc(void *vuc) +void advance_pc(ucontext_t *uc) { - ucontext_t *uc = vuc; uc->uc_mcontext.arm_pc += insnsize(uc); } - -void set_ucontext_paramreg(void *vuc, uint64_t value) +void set_ucontext_paramreg(ucontext_t *uc, uint64_t value) { - ucontext_t *uc = vuc; uc->uc_mcontext.arm_r0 = value; } diff --git a/risu_i386.c b/risu_i386.c index 127e816..5d3b8aa 100644 --- a/risu_i386.c +++ b/risu_i386.c @@ -16,10 +16,8 @@ #include "risu.h" #include "risu_reginfo_i386.h" -void advance_pc(void *vuc) +void advance_pc(ucontext_t *uc) { - ucontext_t *uc = (ucontext_t *) vuc; - /* * We assume that this is UD1 as per get_risuop below. * This would need tweaking if we want to test expected undefs. @@ -27,9 +25,8 @@ void advance_pc(void *vuc) uc->uc_mcontext.gregs[REG_E(IP)] += 3; } -void set_ucontext_paramreg(void *vuc, uint64_t value) +void set_ucontext_paramreg(ucontext_t *uc, uint64_t value) { - ucontext_t *uc = (ucontext_t *) vuc; uc->uc_mcontext.gregs[REG_E(AX)] = value; } diff --git a/risu_loongarch64.c b/risu_loongarch64.c index b6c59cf..921a031 100644 --- a/risu_loongarch64.c +++ b/risu_loongarch64.c @@ -15,15 +15,13 @@ #include "risu.h" -void advance_pc(void *vuc) +void advance_pc(host_context_t *uc) { - struct ucontext *uc = vuc; uc->uc_mcontext.sc_pc += 4; } -void set_ucontext_paramreg(void *vuc, uint64_t value) +void set_ucontext_paramreg(host_context_t *uc, uint64_t value) { - struct ucontext *uc = vuc; uc->uc_mcontext.sc_regs[4] = value; } diff --git a/risu_m68k.c b/risu_m68k.c index acdd57a..bd6bece 100644 --- a/risu_m68k.c +++ b/risu_m68k.c @@ -8,15 +8,13 @@ #include "risu.h" -void advance_pc(void *vuc) +void advance_pc(ucontext_t *uc) { - ucontext_t *uc = (ucontext_t *) vuc; uc->uc_mcontext.gregs[R_PC] += 4; } -void set_ucontext_paramreg(void *vuc, uint64_t value) +void set_ucontext_paramreg(ucontext_t *uc, uint64_t value) { - ucontext_t *uc = vuc; uc->uc_mcontext.gregs[R_A0] = value; } diff --git a/risu_ppc64.c b/risu_ppc64.c index 62cf6aa..06cb8a8 100644 --- a/risu_ppc64.c +++ b/risu_ppc64.c @@ -14,15 +14,13 @@ #include "risu.h" #include -void advance_pc(void *vuc) +void advance_pc(ucontext_t *uc) { - ucontext_t *uc = (ucontext_t *) vuc; uc->uc_mcontext.regs->nip += 4; } -void set_ucontext_paramreg(void *vuc, uint64_t value) +void set_ucontext_paramreg(ucontext_t *uc, uint64_t value) { - ucontext_t *uc = vuc; uc->uc_mcontext.gp_regs[0] = value; } diff --git a/risu_reginfo_loongarch64.c b/risu_reginfo_loongarch64.c index 6150a40..0719e8b 100644 --- a/risu_reginfo_loongarch64.c +++ b/risu_reginfo_loongarch64.c @@ -97,10 +97,9 @@ static int parse_extcontext(struct sigcontext *sc, struct extctx_layout *extctx) } /* reginfo_init: initialize with a ucontext */ -void reginfo_init(struct reginfo *ri, ucontext_t *context, void *siaddr) +void reginfo_init(struct reginfo *ri, host_context_t *uc, void *siaddr) { int i; - struct ucontext *uc = (struct ucontext *)context; struct extctx_layout extctx; memset(&extctx, 0, sizeof(struct extctx_layout)); diff --git a/risu_s390x.c b/risu_s390x.c index cf9c72c..906766e 100644 --- a/risu_s390x.c +++ b/risu_s390x.c @@ -13,7 +13,7 @@ #include "risu.h" -void advance_pc(void *vuc) +void advance_pc(ucontext_t *uc) { /* * Note: The PSW address already points to the next instruction @@ -21,9 +21,8 @@ void advance_pc(void *vuc) */ } -void set_ucontext_paramreg(void *vuc, uint64_t value) +void set_ucontext_paramreg(ucontext_t *uc, uint64_t value) { - ucontext_t *uc = vuc; uc->uc_mcontext.gregs[0] = value; } From patchwork Wed May 22 03:44:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 798143 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:92:b0:351:d90a:5487 with SMTP id m18csp277021wrx; Tue, 21 May 2024 20:45:29 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUafHSCa15J690H+WIhxA7EXSzNmwu2m3AJEK+pCBvi5C703VfvS2a52oP2NBYcKjuOWoqB40onA47zPcZHfLds X-Google-Smtp-Source: AGHT+IE442Y8M4vdiP2Jb72VBpXvroO4oV92qY0PLKZbUUs6M5fVVCJXtVAqsA1r21vxbT6iBZRi X-Received: by 2002:a05:620a:4708:b0:792:b835:19be with SMTP id af79cd13be357-79499457eddmr145081385a.43.1716349528808; Tue, 21 May 2024 20:45:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1716349528; cv=none; d=google.com; s=arc-20160816; b=oOiNRFuEpTC5783WP5zSqAZZMEGBMBOzP3Lb9vMF0qMNeEG4AXPe2luJIi4Ugiyr3I 7H2C5L3/nYgX4fOD/tSNXl3SYuZ7hDImFTCJCjVRx7JYoZ8XSx9GKQ1PhrOj0sKlSfwm o+EglZaFS90NFsTcm3QtrCdC7nAl1M/KulExGjhOrzcVcrcm4miVCEGTbL1/fBdF4TN2 U/yOs0eNrnn3cc2IxdXYsmXWvXqN+wcDLX0vfkxe2dNy3bKirr0pKoVbGjCDzbVBWF6n pHE2xbg4oe6ev0OcBJCw0qNp/1YwtIqCsROy/WcqwsyPrKFL7sIe764yXDn1AmSptmHa xirw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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:cc:to :from:dkim-signature; bh=VQc6zsisJMaVnI573tc7E5e7k10EWW0D4y87pSLLi8M=; fh=aRZTpPWhHXk/ANUEh7k3oMs8V5C8zTe7pkcDFIBzjKg=; b=uLm/LDjT6kDs+g32ZTPiNOQpLhTSmpB9UHrJfdw+pVsg5M2LircsxQRwUrYPHbFqBg BfymwRkRVm3IDqwTJjNNbtnsn9qU+a8QyTTiHXE/xluj0YOlxxmSHV29Q8JDriQ6TMZy JK8RLLoMdLY+9ci1ckY+akKPq8kVj16d2sLhnpp0IglhRKTx66FoHERVMrXneFtBpztd 9ky7x7nkp5XHMwMtlSpdoCVvEEkNjfNZsSo8IWQ2yxSiVMyhqTxr3D9NHIVHuDnOYAyM x9v7zW93dKt3aIgJHRZjpeWuuYYXaXlagIzUMP8qj6mD1E6dpD+2m9fzLemflZqNKEAC xmrg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mYlGyPkS; 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=pass (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 af79cd13be357-792bf33b2b2si757225185a.438.2024.05.21.20.45.28 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 21 May 2024 20:45:28 -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=pass header.i=@linaro.org header.s=google header.b=mYlGyPkS; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s9cuM-0003U1-PG; Tue, 21 May 2024 23:44:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s9cuK-0003SD-BJ for qemu-devel@nongnu.org; Tue, 21 May 2024 23:44:52 -0400 Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s9cuG-0004AE-Ts for qemu-devel@nongnu.org; Tue, 21 May 2024 23:44:51 -0400 Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-6f4472561f1so1120567b3a.0 for ; Tue, 21 May 2024 20:44:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1716349487; x=1716954287; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=VQc6zsisJMaVnI573tc7E5e7k10EWW0D4y87pSLLi8M=; b=mYlGyPkSCXj5LLRz1rrmHmKruzT3WR6VYqlUToUwTCby7xM5OpCeZCtLbBznKFD+K3 G/et5EXSzbjMDysNb4NwKEPuHTOMzIM2wKob/WxnKepE9kjUz5SNRtsjOFazJerJjfQp KBLBLk/oXkW+Z+OFIZD161GJi5Hb8gTzErblwOSDED8AM46pfunZPOtBYPVG9UQPoTRy NVjRA6yo6L4JJDSdtM4fA0gwwpskyJLl/eNDVMyYOyaMSxfxf+uFYQamViWdy4LZPmpt 6ef9xJ8zpR9b+Q3SWGu+ocwWvk7P+489b+k9lqoH9TreVNSOcyIBfTUcxAf8rU22fcGZ KPKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716349487; x=1716954287; 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:message-id:reply-to; bh=VQc6zsisJMaVnI573tc7E5e7k10EWW0D4y87pSLLi8M=; b=vXEf8CWjPthw2B1JV9GomCyrhM5BCFVZjATM2LeZju0uQ0+iWTVV5uxa1OkX6pzH6c R3/nv5/tv3wyaMlATR9suI4WcsxHZa2+Chs51UmHuUzyRwBgim8BletSSZ5isi+l32Kw baA9099lMcOhLusGTbs782MDUF18JfNJd6dUPZ3fHYOEM9Oq2SaBhJsa6Nn5fvsBtypE PVkU7zwlS69nD5EIDXCAe9Ayt4GbH1pA19zG+J7w1Dy1MZpnBp6VHPq87Hy36zyPPggo eLXjgrqha2XAKncho8R1nTP/pxshX3s6gV9VU7+I9hT5+IjUGxlpyk9kTNa7h/h0c2Ga FXhQ== X-Gm-Message-State: AOJu0YxwQaPcU+rbQ4v25Uq88I8K+p8mcPjRwzt3TIK7G3WT+mBUxdPO hWWRSEc79DCww19Nn5ysmX09Osq/26/PGFqMW1eEqPEU8HaSoiiVQwCvSJnr5uBy1BKUNMm3JVF J X-Received: by 2002:a05:6a00:21c9:b0:6f3:e6d6:7fde with SMTP id d2e1a72fcca58-6f6d6171137mr1217830b3a.26.1716349487258; Tue, 21 May 2024 20:44:47 -0700 (PDT) Received: from stoup.. (174-21-72-5.tukw.qwest.net. [174.21.72.5]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-6f4d2af2bafsm21416617b3a.162.2024.05.21.20.44.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 May 2024 20:44:46 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, mark.cave-ayland@ilande.co.uk Subject: [PATCH RISU v2 4/8] risu: Add initial sparc64 support Date: Tue, 21 May 2024 20:44:38 -0700 Message-Id: <20240522034442.140293-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240522034442.140293-1-richard.henderson@linaro.org> References: <20240522034442.140293-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42d; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42d.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=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Best effort for both Linux and Solaris as a host, since the gcc compile farm has more working Sparc Solaris hosts than Sparc Linux hosts. What's missing is a value for %gsr from Solaris. This could complicate comparison of VIS instructions. Signed-off-by: Richard Henderson --- Makefile | 3 + risu_reginfo_sparc64.h | 36 ++++++++ risu.c | 2 + risu_reginfo_sparc64.c | 186 +++++++++++++++++++++++++++++++++++++++++ risu_sparc64.c | 52 ++++++++++++ configure | 2 + test_sparc64.s | 137 ++++++++++++++++++++++++++++++ 7 files changed, 418 insertions(+) create mode 100644 risu_reginfo_sparc64.h create mode 100644 risu_reginfo_sparc64.c create mode 100644 risu_sparc64.c create mode 100644 test_sparc64.s diff --git a/Makefile b/Makefile index 2bd08aa..f503499 100644 --- a/Makefile +++ b/Makefile @@ -53,6 +53,9 @@ $(PROG): $(OBJS) %_$(ARCH).elf: test.ld %_$(ARCH).o $(LD) -o $@ -T $^ +test_sparc64.o: test_sparc64.s + $(AS) -Av9a -o $@ $< + clean: rm -f $(PROG) $(OBJS) $(BINO) $(BINE) diff --git a/risu_reginfo_sparc64.h b/risu_reginfo_sparc64.h new file mode 100644 index 0000000..b1d5341 --- /dev/null +++ b/risu_reginfo_sparc64.h @@ -0,0 +1,36 @@ +/****************************************************************************** + * Copyright (c) 2024 Linaro Limited + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + *****************************************************************************/ + +#ifndef RISU_REGINFO_SPARC64_H +#define RISU_REGINFO_SPARC64_H + +#ifdef __linux__ +typedef struct sigcontext host_context_t; +#else +typedef ucontext_t host_context_t; +#endif + +struct reginfo { + uint32_t faulting_insn; + uint32_t ccr; + + uint64_t pc; + uint64_t npc; + + uint64_t g[8]; + uint64_t o[8]; + uint64_t l[8]; + uint64_t i[8]; + + uint64_t y; + uint64_t fsr; + + uint64_t fregs[32]; +}; + +#endif /* RISU_REGINFO_SPARC64_H */ diff --git a/risu.c b/risu.c index c9c3a38..422b32e 100644 --- a/risu.c +++ b/risu.c @@ -30,6 +30,8 @@ #ifdef __linux__ #include #define HOST_BIG_ENDIAN (__BYTE_ORDER == __BIG_ENDIAN) +#elif defined(__sparc__) +#define HOST_BIG_ENDIAN 1 #else #error Need HOST_BIG_ENDIAN #endif diff --git a/risu_reginfo_sparc64.c b/risu_reginfo_sparc64.c new file mode 100644 index 0000000..be002e3 --- /dev/null +++ b/risu_reginfo_sparc64.c @@ -0,0 +1,186 @@ +/****************************************************************************** + * Copyright (c) 2024 Linaro Limited + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + *****************************************************************************/ + +#include +#include +#include +#include +#include + +#include "risu.h" +#include "risu_reginfo_sparc64.h" + +#define STACK_BIAS 2047 + +const struct option * const arch_long_opts; +const char * const arch_extra_help; + +void process_arch_opt(int opt, const char *arg) +{ + abort(); +} + +void arch_init(void) +{ +} + +int reginfo_size(struct reginfo *ri) +{ + return sizeof(*ri); +} + +/* reginfo_init: initialize with a ucontext */ +void reginfo_init(struct reginfo *ri, host_context_t *hc, void *siaddr) +{ + memset(ri, 0, sizeof(*ri)); + +#ifdef __linux__ + ri->pc = hc->sigc_regs.tpc; + ri->npc = hc->sigc_regs.tnpc; + ri->ccr = (hc->sigc_regs.tstate >> 32) & 0xff; + ri->y = hc->sigc_regs.y; + + /* g + o */ + memcpy(&ri->g, hc->sigc_regs.u_regs, 16 * 8); + /* l + i are just before sc */ + memcpy(&ri->l, (void *)hc - 8 * 8 * 3, 16 * 8); + + if (hc->sigc_fpu_save) { + ri->fsr = hc->sigc_fpu_save->si_fsr; + /* TODO: ri->gsr = hc->sigc_fpu_save->si_gsr; */ + memcpy(ri->fregs, hc->sigc_fpu_save->si_float_regs, 32 * 8); + } +#elif defined(__sun__) + ri->pc = hc->uc_mcontext.gregs[REG_PC]; + ri->npc = hc->uc_mcontext.gregs[REG_nPC]; + ri->ccr = hc->uc_mcontext.gregs[REG_CCR]; + + /* G and O are in the signal frame. */ + memcpy(&ri->g[1], &hc->uc_mcontext.gregs[REG_G1], 7 * sizeof(greg_t)); + memcpy(&ri->o[0], &hc->uc_mcontext.gregs[REG_O0], 8 * sizeof(greg_t)); + + /* L and I are flushed to the regular stack frame. */ + memcpy(&ri->l[0], (void *)(ri->o[6] + STACK_BIAS), 16 * sizeof(greg_t)); + + ri->y = hc->uc_mcontext.gregs[REG_Y]; + ri->fsr = hc->uc_mcontext.fpregs.fpu_fsr; + /* ??? Despite %gsr being asr19, uc->mc.asrs[19-16] is not populated. */ + + memcpy(&ri->fregs[0], &hc->uc_mcontext.fpregs.fpu_fr, + 32 * sizeof(uint64_t)); +#endif + + ri->g[7] = 0xdeadbeefdeadbeeful; /* tp */ + ri->o[6] = 0xdeadbeefdeadbeeful; /* sp */ + ri->i[6] = 0xdeadbeefdeadbeeful; /* fp */ + + ri->faulting_insn = *(uint32_t *)ri->pc; + + ri->pc -= image_start_address; + ri->npc -= image_start_address; +} + +/* reginfo_is_eq: compare the reginfo structs, returns nonzero if equal */ +bool reginfo_is_eq(struct reginfo *r1, struct reginfo *r2) +{ + return memcmp(r1, r2, reginfo_size(r1)) == 0; +} + +/* reginfo_dump: print state to a stream, returns nonzero on success */ +void reginfo_dump(struct reginfo *ri, FILE * f) +{ + int i; + + fprintf(f, " insn : %08x\n", ri->faulting_insn); + fprintf(f, " ccr : %02x\n", ri->ccr); + fprintf(f, " pc : %016" PRIx64 "\n", ri->pc); + fprintf(f, " npc : %016" PRIx64 "\n", ri->npc); + + for (i = 1; i < 8; i++) { + fprintf(f, " G%d : %016" PRIx64 "\n", i, ri->g[i]); + } + for (i = 0; i < 8; i++) { + fprintf(f, " O%d : %016" PRIx64 "\n", i, ri->o[i]); + } + for (i = 0; i < 8; i++) { + fprintf(f, " L%d : %016" PRIx64 "\n", i, ri->l[i]); + } + for (i = 0; i < 8; i++) { + fprintf(f, " I%d : %016" PRIx64 "\n", i, ri->i[i]); + } + + fprintf(f, " y : %016" PRIx64 "\n", ri->y); + fprintf(f, " fsr : %016" PRIx64 "\n", ri->fsr); + + for (i = 0; i < 32; i++) { + fprintf(f, " F%-2d : %016" PRIx64 "\n", i * 2, ri->fregs[i]); + } +} + +/* reginfo_dump_mismatch: print mismatch details to a stream, ret nonzero=ok */ +void reginfo_dump_mismatch(struct reginfo *m, struct reginfo *a, FILE * f) +{ + int i; + + if (m->faulting_insn != a->faulting_insn) { + fprintf(f, " insn : %08x vs %08x\n", + m->faulting_insn, a->faulting_insn); + } + if (m->ccr != a->ccr) { + fprintf(f, " ccr : %02x vs %02x\n", m->ccr, a->ccr); + } + if (m->pc != a->pc) { + fprintf(f, " pc : %016" PRIx64 " vs %016" PRIx64 "\n", + m->pc, a->pc); + } + if (m->npc != a->npc) { + fprintf(f, " npc : %016" PRIx64 " vs %016" PRIx64 "\n", + m->npc, a->npc); + } + + for (i = 1; i < 8; i++) { + if (m->g[i] != a->g[i]) { + fprintf(f, " G%d : %016" PRIx64 " vs %016" PRIx64 "\n", + i, m->g[i], a->g[i]); + } + } + for (i = 0; i < 8; i++) { + if (m->o[i] != a->o[i]) { + fprintf(f, " O%d : %016" PRIx64 " vs %016" PRIx64 "\n", + i, m->o[i], a->o[i]); + } + } + for (i = 0; i < 8; i++) { + if (m->l[i] != a->l[i]) { + fprintf(f, " L%d : %016" PRIx64 " vs %016" PRIx64 "\n", + i, m->l[i], a->l[i]); + } + } + for (i = 0; i < 8; i++) { + if (m->i[i] != a->i[i]) { + fprintf(f, " I%d : %016" PRIx64 " vs %016" PRIx64 "\n", + i, m->i[i], a->i[i]); + } + } + + if (m->y != a->y) { + fprintf(f, " y : %016" PRIx64 " vs %016" PRIx64 "\n", + m->y, a->y); + } + if (m->fsr != a->fsr) { + fprintf(f, " fsr : %016" PRIx64 " vs %016" PRIx64 "\n", + m->fsr, a->fsr); + } + + for (i = 0; i < 32; i++) { + if (m->fregs[i] != a->fregs[i]) { + fprintf(f, " F%-2d : %016" PRIx64 " vs %016" PRIx64 "\n", + i * 2, m->fregs[i], a->fregs[i]); + } + } +} diff --git a/risu_sparc64.c b/risu_sparc64.c new file mode 100644 index 0000000..48b5cfe --- /dev/null +++ b/risu_sparc64.c @@ -0,0 +1,52 @@ +/****************************************************************************** + * Copyright (c) 2024 Linaro Limited + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + *****************************************************************************/ + +#include +#include "risu.h" + +void advance_pc(host_context_t *hc) +{ +#ifdef __linux__ + hc->sigc_regs.tpc = hc->sigc_regs.tnpc; + hc->sigc_regs.tnpc += 4; +#else + hc->uc_mcontext.gregs[REG_PC] = hc->uc_mcontext.gregs[REG_nPC]; + hc->uc_mcontext.gregs[REG_nPC] += 4; +#endif +} + +void set_ucontext_paramreg(host_context_t *hc, uint64_t value) +{ +#ifdef __linux__ + hc->sigc_regs.u_regs[15] = value; +#else + hc->uc_mcontext.gregs[REG_O7] = value; +#endif +} + +uint64_t get_reginfo_paramreg(struct reginfo *ri) +{ + return ri->o[7]; +} + +RisuOp get_risuop(struct reginfo *ri) +{ + /* Return the risuop we have been asked to do + * (or OP_SIGILL if this was a SIGILL for a non-risuop insn) + */ + uint32_t insn = ri->faulting_insn; + uint32_t op = insn & 0xf; + uint32_t key = insn & ~0xf; + uint32_t risukey = 0x000dead0; + return (key != risukey) ? OP_SIGILL : op; +} + +uintptr_t get_pc(struct reginfo *ri) +{ + return ri->pc; +} diff --git a/configure b/configure index 39275a2..965f338 100755 --- a/configure +++ b/configure @@ -62,6 +62,8 @@ guess_arch() { ARCH="ppc64" elif check_define __s390x__ ; then ARCH="s390x" + elif check_define __sparc__ && check_define __arch64__ ; then + ARCH="sparc64" else echo "This cpu is not supported by risu. Try -h. " >&2 exit 1 diff --git a/test_sparc64.s b/test_sparc64.s new file mode 100644 index 0000000..c131d81 --- /dev/null +++ b/test_sparc64.s @@ -0,0 +1,137 @@ +/***************************************************************************** + * Copyright (c) 2024 Linaro Limited + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + *****************************************************************************/ + +/* Initialise the fp regs */ + + .register %g2, #ignore + .register %g3, #ignore + .register %g6, #ignore + +.text + rd %pc, %g1 + sethi %pc22(.Ldata+4), %g2 + or %g2, %pc10(.Ldata+8), %g2 + add %g2, %g1, %g1 + + ldd [%g1 + 4 * 0], %f0 + ldd [%g1 + 4 * 2], %f2 + ldd [%g1 + 4 * 4], %f4 + ldd [%g1 + 4 * 6], %f6 + ldd [%g1 + 4 * 8], %f8 + ldd [%g1 + 4 * 10], %f10 + ldd [%g1 + 4 * 12], %f12 + ldd [%g1 + 4 * 14], %f14 + ldd [%g1 + 4 * 16], %f16 + ldd [%g1 + 4 * 18], %f18 + ldd [%g1 + 4 * 20], %f20 + ldd [%g1 + 4 * 22], %f22 + ldd [%g1 + 4 * 24], %f24 + ldd [%g1 + 4 * 26], %f26 + ldd [%g1 + 4 * 28], %f28 + ldd [%g1 + 4 * 30], %f30 + ldd [%g1 + 4 * 32], %f32 + ldd [%g1 + 4 * 34], %f34 + ldd [%g1 + 4 * 36], %f36 + ldd [%g1 + 4 * 38], %f38 + ldd [%g1 + 4 * 40], %f40 + ldd [%g1 + 4 * 42], %f42 + ldd [%g1 + 4 * 44], %f44 + ldd [%g1 + 4 * 46], %f46 + ldd [%g1 + 4 * 48], %f48 + ldd [%g1 + 4 * 50], %f50 + ldd [%g1 + 4 * 52], %f52 + ldd [%g1 + 4 * 54], %f54 + ldd [%g1 + 4 * 56], %f56 + ldd [%g1 + 4 * 58], %f58 + ldd [%g1 + 4 * 60], %f60 + ldd [%g1 + 4 * 62], %f62 + +/* Initialize the special regs */ + + wr %g0, 0x100, %y + wr %g0, 0x200, %gsr + cmp %g0, %g0 + +/* Initialise the gp regs */ + + mov 1, %g1 + mov 2, %g2 + mov 3, %g3 + mov 4, %g4 + mov 5, %g5 + mov 6, %g6 + /* g7 is the thread pointer */ + + mov 8, %o0 + mov 9, %o1 + mov 10, %o2 + mov 11, %o3 + mov 12, %o4 + mov 13, %o5 + /* o6 is the stack pointer */ + mov 15, %o7 + + mov 16, %l0 + mov 17, %l1 + mov 18, %l2 + mov 19, %l3 + mov 20, %l4 + mov 21, %l5 + mov 22, %l6 + mov 23, %l7 + + mov 24, %i0 + mov 25, %i1 + mov 26, %i2 + mov 27, %i3 + mov 28, %i4 + mov 29, %i5 + /* i6 is the frame pointer */ + mov 31, %i7 + +/* Do compare. */ + + illtrap 0xdead0 + illtrap 0xdead1 + +.data + .align 8 +.Ldata: + .double 1 + .double 2 + .double 3 + .double 4 + .double 5 + .double 6 + .double 7 + .double 8 + .double 9 + .double 10 + .double 11 + .double 12 + .double 13 + .double 14 + .double 15 + .double 16 + .double 17 + .double 18 + .double 19 + .double 20 + .double 21 + .double 22 + .double 23 + .double 24 + .double 25 + .double 26 + .double 27 + .double 28 + .double 29 + .double 30 + .double 31 + .double 32 + From patchwork Wed May 22 03:44:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 798148 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:92:b0:351:d90a:5487 with SMTP id m18csp277144wrx; Tue, 21 May 2024 20:46:03 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWUgW2tEibCHxnSp7UPFGwQ/mPh53cByQf/w1T3rKzm1FrFCtD0juehXL63xsw0lAybdd5RKGao6DQdiJ8ODEqv X-Google-Smtp-Source: AGHT+IGCXZNLhCm6ShYFOYNtRapdK29B6NK5i10hlreQRY+St2FQbtlyvv0H2PmqbgWybGX1YSIR X-Received: by 2002:a37:e211:0:b0:792:bb2c:9737 with SMTP id af79cd13be357-794994566f5mr87893585a.40.1716349562861; Tue, 21 May 2024 20:46:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1716349562; cv=none; d=google.com; s=arc-20160816; b=VcZdM7JS+QVRJtLE9EJLOLcJtO+CVMH+dRtVoX3rcLJmiprlIqz2XlMRv0I2H0P8RH SsP2iXCrC1eDPTFPj9j643TMI8GPPoXFPAJaL3UWj/rUE0rUH/tEtbwYENsN9NzZnmfm KZiEjksK7zEUaXZVY5Mn27gszCDgLQYkVNE8qFKwk4EWH+vz4iigc6sToCAFJ6zwQWGP rM8FVIae6P5BbTmDSZp3gB2OokDAtWr1XYIHtM3DS9JAGzBIITFozecE53odYWW2CfiU kpQzJtnN98um2kG23Zf1iloXi4Ee4sY+GUFu82eE+TLFHh3o7e4ox3shQyzCz0mBV8iR UGSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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:cc:to :from:dkim-signature; bh=ANXC48sQiPcmwS+xOFwDre7pgTyWtySeXqXMB92Q6A0=; fh=aRZTpPWhHXk/ANUEh7k3oMs8V5C8zTe7pkcDFIBzjKg=; b=WjfpVmmu4jMCf23lyEiP0EP9+o0c2zHiu07nNjBP+yP6r46w5HmMm30Xg3RH05/iM2 0oRj54eH3yUwvOojpnU1Zjavtm/S7pxaI+YkZfw6L7/DB3MsE7rRjb2uUhYMQ3dc11WK QQU8rNSgROJQ8deuvZMLdY9KnD69Eldu3E39GwG3mtApD3JrbVUPeXWWiS/k5NQbqJCa Kk2EWYpN6f0eAdhy+f2vzooduu/5bG9nY5sK7QplwA0uHEoMkod/rtpPv9vlezzrOfp9 1valriVWKffg786sQvyP05qSgocy84colJTyN51mOEROBbAc40ACtQoR+DrBny/a2bor g87Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KXpx+4jg; 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=pass (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 af79cd13be357-793021afd9dsi382509485a.313.2024.05.21.20.46.02 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 21 May 2024 20:46:02 -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=pass header.i=@linaro.org header.s=google header.b=KXpx+4jg; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s9cuL-0003Su-3M; Tue, 21 May 2024 23:44:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s9cuJ-0003Rd-5w for qemu-devel@nongnu.org; Tue, 21 May 2024 23:44:51 -0400 Received: from mail-oi1-x22b.google.com ([2607:f8b0:4864:20::22b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s9cuH-0004AG-Dj for qemu-devel@nongnu.org; Tue, 21 May 2024 23:44:50 -0400 Received: by mail-oi1-x22b.google.com with SMTP id 5614622812f47-3c99257e0cbso2559931b6e.3 for ; Tue, 21 May 2024 20:44:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1716349488; x=1716954288; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ANXC48sQiPcmwS+xOFwDre7pgTyWtySeXqXMB92Q6A0=; b=KXpx+4jgwPxFEJQAB6kaBqdAkphKeWZ6wDTgybIPtWiBukj5AyZd27DGCrMXEYH0QG DhPjV09mU/NG48nvU52e1s5ZDhVUJnigYO0N99vXTDe1O9ES98RSPuJjII4m0UrN2EX4 ND3PaCHjVj8kz7cNKtbsQKSmHEO6rm3JZue6jze2a9t+NXjYIGUvD5XZIbdMjukaw+FP Gd1aq6I3JGems8c9pqXNZm3X46PKQbv0kNdjcf9QQwD88J3bD7aMX0HIYaAbOeqmqppT S+fdp65ffCEtcq71KP7XLwkNrV5BWmmKMQB/zaIrXh/rf6RI+boITlAM5/s64r16Q4Hw SoKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716349488; x=1716954288; 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:message-id:reply-to; bh=ANXC48sQiPcmwS+xOFwDre7pgTyWtySeXqXMB92Q6A0=; b=CL7pd8d/JrgzTgpZr84Qz0D1KM7Zg7vnASgoDpRcifEQ8UyBuogRT2qBzUyfwObdG0 CojdLt75sirmrgzQMU8ialOJGkZG+ojIMG0Rat5AL+dIzKWle6Qy5TBySGvKPIiNR4Zw CxU0eAAIF/64mBLbVf2m1a0bD970fKmZVQeE/mdf+JwPr5szySO31qHlRy+AS6D6+/nB RD4u/XKRJHzSrU0nefzPsHP/aOEImd3vimAiMQpv52ycXkuvfHawGDgiEvLLj+JyMvCS 9LRwUqCy/5yW/eEq4qeFTfY1rtyBu4njC4Dp+8MSQBqvxan8nk7MCP33yY1C7UxEj7FF NltA== X-Gm-Message-State: AOJu0Yxy2in6sYQodtmb4IPE9KMackuBODId1jxotePRRyLp5SOBATOt jG8ehu92SRQ1gyZbs13YWlwsCLgWRo4osIEwGCoJ3G8Sdcus9yDQNcyzwteMu7td0QJEDdQ/+6q 6 X-Received: by 2002:a05:6808:9a9:b0:3c9:94f2:5cae with SMTP id 5614622812f47-3cdb32e44b0mr997628b6e.17.1716349488011; Tue, 21 May 2024 20:44:48 -0700 (PDT) Received: from stoup.. (174-21-72-5.tukw.qwest.net. [174.21.72.5]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-6f4d2af2bafsm21416617b3a.162.2024.05.21.20.44.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 May 2024 20:44:47 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, mark.cave-ayland@ilande.co.uk Subject: [PATCH RISU v2 5/8] risugen: Be explicit about print destinations Date: Tue, 21 May 2024 20:44:39 -0700 Message-Id: <20240522034442.140293-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240522034442.140293-1-richard.henderson@linaro.org> References: <20240522034442.140293-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::22b; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x22b.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=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Printing directly to STDOUT and STDERR will allow the print destination to be selected elsewhere. Signed-off-by: Richard Henderson --- risugen_common.pm | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/risugen_common.pm b/risugen_common.pm index 71ee996..5207c0e 100644 --- a/risugen_common.pm +++ b/risugen_common.pm @@ -76,7 +76,7 @@ sub progress_start($$) ($proglen, $progmax) = @_; $proglen -= 2; # allow for [] chars $| = 1; # disable buffering so we can see the meter... - print "[" . " " x $proglen . "]\r"; + print STDOUT "[" . " " x $proglen . "]\r"; $lastprog = 0; } @@ -87,13 +87,13 @@ sub progress_update($) my $barlen = int($proglen * $done / $progmax); if ($barlen != $lastprog) { $lastprog = $barlen; - print "[" . "-" x $barlen . " " x ($proglen - $barlen) . "]\r"; + print STDOUT "[" . "-" x $barlen . " " x ($proglen - $barlen) . "]\r"; } } sub progress_end() { - print "[" . "-" x $proglen . "]\n"; + print STDOUT "[" . "-" x $proglen . "]\n"; $| = 0; } @@ -124,7 +124,7 @@ sub eval_with_fields($$$$$) { $evalstr .= "}"; my $v = eval $evalstr; if ($@) { - print "Syntax error detected evaluating $insnname $blockname string:\n$block\n$@"; + print STDERR "Syntax error detected evaluating $insnname $blockname string:\n$block\n$@"; exit(1); } return $v; @@ -163,20 +163,20 @@ sub dump_insn_details($$) { # Dump the instruction details for one insn my ($insn, $rec) = @_; - print "insn $insn: "; + print STDOUT "insn $insn: "; my $insnwidth = $rec->{width}; my $fixedbits = $rec->{fixedbits}; my $fixedbitmask = $rec->{fixedbitmask}; my $constraint = $rec->{blocks}{"constraints"}; - print sprintf(" insnwidth %d fixedbits %08x mask %08x ", $insnwidth, $fixedbits, $fixedbitmask); + print STDOUT sprintf(" insnwidth %d fixedbits %08x mask %08x ", $insnwidth, $fixedbits, $fixedbitmask); if (defined $constraint) { - print "constraint $constraint "; + print STDOUT "constraint $constraint "; } for my $tuple (@{ $rec->{fields} }) { my ($var, $pos, $mask) = @$tuple; - print "($var, $pos, " . sprintf("%08x", $mask) . ") "; + print STDOUT "($var, $pos, " . sprintf("%08x", $mask) . ") "; } - print "\n"; + print STDOUT "\n"; } 1; From patchwork Wed May 22 03:44:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 798147 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:92:b0:351:d90a:5487 with SMTP id m18csp277140wrx; Tue, 21 May 2024 20:46:00 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWqNshQzFc5m5rOfvREJBKMhrZs9/MU01xQkOIPaW8gwRez5hy8MTocsz0QRLp9ivPzJ5ofB35JUSny2RnWVk8K X-Google-Smtp-Source: AGHT+IE7o2HQx/EDnoOJoDvU45t18f7Lph4/Mrj5xcz0OiSdrFcWrSInRq3UyL4sTEWY2YwoVvBE X-Received: by 2002:a05:620a:1a2a:b0:792:f3b0:c64a with SMTP id af79cd13be357-79470f0c013mr1858351185a.31.1716349560100; Tue, 21 May 2024 20:46:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1716349560; cv=none; d=google.com; s=arc-20160816; b=t7AKOPgM6iJA97FIVCcuS7eb/UnfYB1c+GwQzPldYyDzLb0sSRBGgoCGt8UDbh0uh4 jUJsUcbFT4nsHXUXHUG+KVwqJd7TfQCNuY6y46K6l6FrHSVKOK6dmsGBO0VRQpQUysCL oGt1OcTkzq7irWUfHMo33vr0QRmlEjorWJH14oiMSZ4mJV27+DhMeAapgxtaaNThdLwq qHq59GZTw70wIfuw/0Fl2kgfREk45vbp4+BbKTZ7hP2CpH+qrVGVnniJWY3aanzIHSzd BcFOUNOy7JZgrg15ddivH0woult0vkKmtLU+aI2lhMKW6cVykVCXD2QQ3XZyHf7DFC4U arYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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:cc:to :from:dkim-signature; bh=MCy66KKepWlHqXyVaIB/ACSSH0v8RsXCcqK/IUUC3fY=; fh=aRZTpPWhHXk/ANUEh7k3oMs8V5C8zTe7pkcDFIBzjKg=; b=BQ6tpF11B8bWyIw0WUFED7xA7Int0ReYRKKpM+tlayVER2RBGFMCuMmKcMeW+2eiqZ RTr4pRN45+HyEzpZ5yEgltXHRgAyGJywWv4jD1AdoS+rjTs9oG9WcXJs+b4k2i9aNbuY /2kh+m0Bq2jLnkJ7Pnae5mFmpeYViBCb4OkSnKYoiQSBGuu9mwleFBBVZGxLwhVUZ30j +VO1T0BUIGoyp/8Goo3mXLt+N36iJrNrF0W9llMjN7qYDjJFraJqWs/m22hZ3tPrHE4h oUav1ipB4tUx21kHtpMnH7cBIkUhhNa6ZK/cam0NU4MFtzP8o4oMCuK/5x34mKlkQ2LO OHrA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kXNUSnbn; 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=pass (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 af79cd13be357-792bf36a4f4si228475985a.676.2024.05.21.20.45.59 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 21 May 2024 20:46:00 -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=pass header.i=@linaro.org header.s=google header.b=kXNUSnbn; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s9cuO-0003Un-03; Tue, 21 May 2024 23:44:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s9cuM-0003U0-N5 for qemu-devel@nongnu.org; Tue, 21 May 2024 23:44:54 -0400 Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s9cuI-0004By-IH for qemu-devel@nongnu.org; Tue, 21 May 2024 23:44:53 -0400 Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-6f4603237e0so366377b3a.0 for ; Tue, 21 May 2024 20:44:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1716349489; x=1716954289; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=MCy66KKepWlHqXyVaIB/ACSSH0v8RsXCcqK/IUUC3fY=; b=kXNUSnbnQne6oUbjAO2SXHzZHU5383wEUr8ds5O64Toqf75aCpQ3VCkM+1NpSFdJgI XBBCpf/0ZDzMM9tnJlq+aCbBNM6tg/bvJz85GKk4wUPf/7E4ikV5t93AJF/bnKLQq2Sx +yneEELpe3ZE1M5LeKLgVlzqy6kYaZhxSe6zIeBxq0aMyCtdRiu8lCeam5jAbGfElJso HmnliWu8OYP94DOz+xDIsvhviw/0XEajBMSG8rOJo1HrOqqKVZMOjyYLXWzw1vH8BKcH RgG/U49CEVUDcF22IZsBcvSCCTGNpRXgPCCKWMKFd+zTieACMMP6jlrQa9Ja3n4kI2nw SC1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716349489; x=1716954289; 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:message-id:reply-to; bh=MCy66KKepWlHqXyVaIB/ACSSH0v8RsXCcqK/IUUC3fY=; b=FURkK19VjCbH8oyiqOF3mTWVJCL/sFSiGUhXWZ49gB+O6S8eJsPiZHkJhKrX43aPty ftcaCESsQYZfo7nWk53l2du4wA0CAVAL2YnimdgS9bf1kQXEOmC2HE9b03ENDTRbft+n +Y/3oPMxUOcgRdBBsCu9qSl3j751m0QSlOZa7LtXEuFkF0kaL4N64+WeqP7HykLU6IVj mP891AXbmNqmTMxLZbPaopShzERLHCW48qCZcjfMqm67qJP3t1DUlvPfE8+2KjvM/T+N msA1EN+6xUa+akcL/ThmDhQDPkQIdUcjQBpMw80UJFJaZX92rWiOsWW11Y1BOQzh5mEi wedg== X-Gm-Message-State: AOJu0YzgKB7wjgSUH2cpWtQ7q3R7TgwfTj5NMUZsEQQlRVYl+jYk1jvh A4diIRsac+9OPKgcHhpyYIDHO5SFk6eMyrHX0E2o8zCJTVXIKQNbjC43+Z6o/AWEq9NR5oENOE/ i X-Received: by 2002:a05:6a00:4644:b0:6ea:ed87:1348 with SMTP id d2e1a72fcca58-6f6d57166bamr1365492b3a.13.1716349489020; Tue, 21 May 2024 20:44:49 -0700 (PDT) Received: from stoup.. (174-21-72-5.tukw.qwest.net. [174.21.72.5]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-6f4d2af2bafsm21416617b3a.162.2024.05.21.20.44.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 May 2024 20:44:48 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, mark.cave-ayland@ilande.co.uk Subject: [PATCH RISU v2 6/8] risugen: Add sparc64 support Date: Tue, 21 May 2024 20:44:40 -0700 Message-Id: <20240522034442.140293-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240522034442.140293-1-richard.henderson@linaro.org> References: <20240522034442.140293-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42d; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42d.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=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Signed-off-by: Richard Henderson --- risugen | 10 +- risugen_common.pm | 50 +++++- risugen_sparc64.pm | 385 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 443 insertions(+), 2 deletions(-) create mode 100644 risugen_sparc64.pm diff --git a/risugen b/risugen index 2800b8b..830dfd3 100755 --- a/risugen +++ b/risugen @@ -310,6 +310,8 @@ Valid options: Useful to test before support for FP is available. --sve : enable sve floating point --be : generate instructions in Big-Endian byte order (ppc64 only). + --cross prefix : prefix for the assembler and linker + --keep : do not remove intermediate files --help : print this message EOT } @@ -322,6 +324,8 @@ sub main() my $fp_enabled = 1; my $sve_enabled = 0; my $big_endian = 0; + my $cross_prefix = ""; + my $keep = 0; my ($infile, $outfile); GetOptions( "help" => sub { usage(); exit(0); }, @@ -339,6 +343,8 @@ sub main() "be" => sub { $big_endian = 1; }, "no-fp" => sub { $fp_enabled = 0; }, "sve" => sub { $sve_enabled = 1; }, + "cross-prefix=s" => \$cross_prefix, + "keep" => sub { $keep = 1; }, ) or return 1; # allow "--pattern re,re" and "--pattern re --pattern re" @pattern_re = split(/,/,join(',',@pattern_re)); @@ -372,7 +378,9 @@ sub main() 'keys' => \@insn_keys, 'arch' => $full_arch[0], 'subarch' => $full_arch[1] || '', - 'bigendian' => $big_endian + 'bigendian' => $big_endian, + 'cross_prefix' => $cross_prefix, + 'keep' => $keep, ); write_test_code(\%params); diff --git a/risugen_common.pm b/risugen_common.pm index 5207c0e..228082f 100644 --- a/risugen_common.pm +++ b/risugen_common.pm @@ -26,7 +26,8 @@ BEGIN { our @EXPORT = qw(open_bin close_bin set_endian insn32 insn16 $bytecount progress_start progress_update progress_end eval_with_fields is_pow_of_2 sextract ctz - dump_insn_details); + dump_insn_details + open_asm close_asm assemble_and_link); } our $bytecount; @@ -66,6 +67,53 @@ sub insn16($) $bytecount += 2; } +sub open_asm($) +{ + my ($basename) = @_; + my $fname = $basename . ".s"; + open(ASM, ">", $fname) or die "can't open $fname: $!"; + select ASM; +} + +sub close_asm +{ + close(ASM) or die "can't close asm file: $!"; + select STDOUT; +} + +sub assemble_and_link($$$@) +{ + my ($basename, $cross_prefix, $keep, @asflags) = @_; + my $asmfile = $basename . ".s"; + my $ldfile = $basename . ".ld"; + my $objfile = $basename . ".o"; + + open(LD, ">", $ldfile) or die "can't open $ldfile: $!"; + print LD ' + ENTRY(start) + PHDRS { text PT_LOAD FILEHDR PHDRS; } + SECTIONS { + . = SIZEOF_HEADERS; + PROVIDE(start = .); + .text : { *(.text) } :text + .data : { *(.data) } :text + } + '; + close(LD); + + my @as = ($cross_prefix . "as", @asflags, "-o", $objfile, $asmfile); + system(@as) == 0 or die "system @as failed: $?"; + + my @ld = ($cross_prefix . "ld", "-o", $basename, "-T", $ldfile, $objfile); + system(@ld) == 0 or die "system @ld failed: $?"; + + if (!$keep) { + unlink $asmfile; + unlink $ldfile; + unlink $objfile; + } +} + # Progress bar implementation my $lastprog; my $proglen; diff --git a/risugen_sparc64.pm b/risugen_sparc64.pm new file mode 100644 index 0000000..c9f2ede --- /dev/null +++ b/risugen_sparc64.pm @@ -0,0 +1,385 @@ +#!/usr/bin/perl -w +############################################################################### +# Copyright (c) 2024 Linaro Limited +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +############################################################################### + +# risugen -- generate a test binary file for use with risu +# See 'risugen --help' for usage information. +package risugen_sparc64; + +use strict; +use warnings; + +use risugen_common; + +require Exporter; + +our @ISA = qw(Exporter); +our @EXPORT = qw(write_test_code); + +my $periodic_reg_random = 1; + +# Maximum alignment restriction permitted for a memory op. +my $MAXALIGN = 64; +my $MAXBLOCK = 2048; +my $PARAMREG = 15; # %o7 + +my $OP_COMPARE = 0; # compare registers +my $OP_TESTEND = 1; # end of test, stop +my $OP_SETMEMBLOCK = 2; # g1 is address of memory block (8192 bytes) +my $OP_GETMEMBLOCK = 3; # add the address of memory block to g1 +my $OP_COMPAREMEM = 4; # compare memory block + +my @GREGS = ( "%g0", "%g1", "%g2", "%g3", "%g4", "%g5", "%g6", "%g7", + "%o0", "%o1", "%o2", "%o3", "%o4", "%o5", "%o6", "%o7", + "%l0", "%l1", "%l2", "%l3", "%l4", "%l5", "%l6", "%l7", + "%i0", "%i1", "%i2", "%i3", "%i4", "%i5", "%i6", "%i7" ); + +sub write_data32($) +{ + my ($val) = @_; + printf "\t.word\t%#x\n", $val; +} + +sub write_data64($) +{ + my ($val) = @_; + printf "\t.quad\t%#x\n", $val; +} + +sub write_risuop($) +{ + my ($op) = @_; + printf "\tilltrap\t%#x\n", 0xdead0 + $op; +} + +sub write_mov_rr($$) +{ + my ($rd, $rs) = @_; + printf "\tmov\t%s,%s\n", $GREGS[$rs], $GREGS[$rd]; +} + +sub write_mov_ri($$) +{ + my ($rd, $imm) = @_; + + if (-0x1000 <= $imm < 0x1000) { + printf "\tmov\t%d,%s\n", $imm, $GREGS[$rd]; + } else { + my $immhi = $imm & 0xfffff000; + my $immlo = $imm & 0x00000fff; + + if ($imm < 0) { + $immhi ^= 0xfffff000; + $immlo |= -0x1000; + } + printf "\tsethi\t%%hi(%d),%s\n", $immhi, $GREGS[$rd]; + if ($immlo != 0) { + printf "\txor\t%s,%d,%s\n", $GREGS[$rd], $immlo, $GREGS[$rd]; + } + } +} + +sub write_add_rri($$$) +{ + my ($rd, $rs, $imm) = @_; + die "bad imm!" if ($imm < -0x1000 || $imm >= 0x1000); + + printf "\txor\t%s,%d,%s\n", $GREGS[$rs], $imm, $GREGS[$rd]; +} + +sub write_sub_rrr($$$) +{ + my ($rd, $rs1, $rs2) = @_; + + printf "\tsub\t%s,%s,%s\n", $GREGS[$rs1], $GREGS[$rs2], $GREGS[$rd]; +} + +sub begin_datablock($$) +{ + my ($align, $label) = @_; + die "bad align!" if ($align < 4 || $align > 255 || !is_pow_of_2($align)); + + printf ".data\n"; + printf "\t.balign %d\n", $align; + printf "%s:\n", $label; +} + +sub end_datablock() +{ + printf ".text\n" +} + +sub write_ref_datablock($$$$) +{ + my ($rd, $offset, $scratch, $label) = @_; + + printf "\trd\t%%pc,%s\n", $GREGS[$rd]; + printf "\tsethi\t%%pc22(%s+%d),%s\n", + $label, $offset + 4, $GREGS[$scratch]; + printf "\tor\t%s,%%pc10(%s+%d),%s\n", + $GREGS[$scratch], $label, $offset + 8, $GREGS[$scratch]; + printf "\tadd\t%s,%s,%s\n", $GREGS[$scratch], $GREGS[$rd], $GREGS[$rd]; +} + +sub write_random_register_data($$) +{ + my ($fp_enabled, $fsr) = @_; + my $size = 32 * 8; + + if ($fp_enabled) { + # random data for 32 double-precision regs plus %gsr + $size += $fp_enabled ? 33 * 8 : 0; + } + + begin_datablock(8, "1"); + for (my $i = 0; $i < $size; $i += 4) { + write_data32(rand(0xffffffff)); + } + if ($fp_enabled) { + # %fsr gets constant data + write_data64($fsr); + } + end_datablock(); + + write_ref_datablock(1, 0, 2, "1b"); + + # Load floating point / SIMD registers + if ($fp_enabled) { + for (my $rt = 0; $rt < 64; $rt += 2) { + printf "\tldd\t[%s+%d],%%f%d\n", $GREGS[1], 32 * 8 + $rt * 4, $rt; + } + printf "\tldx\t[%s+%d],%s\n", $GREGS[1], 64 * 8, $GREGS[2]; + printf "\twr\t%s,0,%%gsr\n", $GREGS[2]; + printf "\tldx\t[%s+%d],%%fsr\n", $GREGS[1], 65 * 8; + } + + # Load Y + printf "\tldx\t[%s],%s\n", $GREGS[1], $GREGS[2]; + printf "\twr\t%s,0,%%y\n", $GREGS[2]; + + # Clear flags + printf "\twr\t%%g0,0,%%ccr\n"; + + # Load general purpose registers + for (my $i = 31; $i >= 1; --$i) { + if (reg_ok($i)) { + printf "\tldx\t[%s+%d],%s\n", $GREGS[1], $i * 8, $GREGS[$i]; + } + } + + write_risuop($OP_COMPARE); +} + +sub write_memblock_setup() +{ + begin_datablock($MAXALIGN, "2"); + + for (my $i = 0; $i < $MAXBLOCK; $i += 4) { + write_data32(rand(0xffffffff)); + } + + end_datablock(); + write_ref_datablock($PARAMREG, 0, 1, "2b"); + write_risuop($OP_SETMEMBLOCK); +} + +# Functions used in memory blocks to handle addressing modes. +# These all have the same basic API: they get called with parameters +# corresponding to the interesting fields of the instruction, +# and should generate code to set up the base register to be +# valid. They must return the register number of the base register. +# The last (array) parameter lists the registers which are trashed +# by the instruction (ie which are the targets of the load). +# This is used to avoid problems when the base reg is a load target. + +# Global used to communicate between align(x) and reg() etc. +my $alignment_restriction; + +sub align($) +{ + my ($a) = @_; + if (!is_pow_of_2($a) || !(0 < $a <= $MAXALIGN)) { + die "bad align() value $a\n"; + } + $alignment_restriction = $a; +} + +sub gen_memblock_offset() +{ + # Generate a random offset within the memory block, of the correct + # alignment. We require the offset to not be within 16 bytes of either + # end, to (more than) allow for the worst case data transfer. + return (rand($MAXBLOCK - 32) + 16) & ~($alignment_restriction - 1); +} + +sub reg_ok($) +{ + my ($r) = @_; + + # Avoid special registers %g7 (tp), %o6 (sp), %i6 (fp). + return $r != 7 && $r != 14 && $r != 30; +} + +sub reg_plus_imm($$@) +{ + # Handle reg + immediate addressing mode + my ($base, $imm, @trashed) = @_; + my $offset = gen_memblock_offset(); + my $scratch = $base != 1 ? 1 : 2; + + write_ref_datablock($base, $offset - $imm, $scratch, "2b"); + write_mov_ri($scratch, 0); + + if (grep $_ == $base, @trashed) { + return -1; + } + return $base; +} + +sub reg($@) +{ + my ($base, @trashed) = @_; + return reg_plus_imm($base, 0, @trashed); +} + +sub reg_plus_reg($$@) +{ + # Handle reg + reg addressing mode + my ($base, $idx, @trashed) = @_; + my $offset = gen_memblock_offset(); + my $scratch = 1; + + if ($base == $idx) { + return -1; + } + + while ($base == $scratch || $idx == $scratch) { + ++$scratch; + } + + write_ref_datablock($base, $offset, $scratch, "2b"); + write_mov_ri($scratch, 0); + write_sub_rrr($base, $base, $idx); + + if (grep $_ == $base, @trashed) { + return -1; + } + return $base; +} + +sub gen_one_insn($) +{ + my ($rec) = @_; + my $insnname = $rec->{name}; + my $insnwidth = $rec->{width}; + my $fixedbits = $rec->{fixedbits}; + my $fixedbitmask = $rec->{fixedbitmask}; + my $constraint = $rec->{blocks}{"constraints"}; + my $memblock = $rec->{blocks}{"memory"}; + + # Given an instruction-details array, generate an instruction + my $constraintfailures = 0; + + INSN: while(1) { + my $insn = int(rand(0xffffffff)); + + $insn &= ~$fixedbitmask; + $insn |= $fixedbits; + + if (defined $constraint) { + # User-specified constraint: evaluate in an environment + # with variables set corresponding to the variable fields. + my $v = eval_with_fields($insnname, $insn, $rec, "constraints", $constraint); + if (!$v) { + $constraintfailures++; + if ($constraintfailures > 10000) { + print "10000 consecutive constraint failures for $insnname constraints string:\n$constraint\n"; + exit (1); + } + next INSN; + } + } + + # OK, we got a good one + $constraintfailures = 0; + + my $basereg; + + if (defined $memblock) { + # This is a load or store. We simply evaluate the block, + # which is expected to be a call to a function which emits + # the code to set up the base register and returns the + # number of the base register. + align(16); + $basereg = eval_with_fields($insnname, $insn, $rec, "memory", $memblock); + } + + write_data32($insn); + + if (defined $memblock) { + # Clean up following a memory access instruction: + # we need to turn the (possibly written-back) basereg + # into an offset from the base of the memory block, + # to avoid making register values depend on memory layout. + # $basereg -1 means the basereg was a target of a load + # (and so it doesn't contain a memory address after the op) + if ($basereg != -1) { + write_mov_ri($basereg, 0); + } + write_risuop($OP_COMPAREMEM); + } + return; + } +} + +sub write_test_code($) +{ + my ($params) = @_; + + my $fp_enabled = $params->{ 'fp_enabled' }; + my $fsr = $params->{ 'fpscr' }; + my $numinsns = $params->{ 'numinsns' }; + my $outfile = $params->{ 'outfile' }; + + my %insn_details = %{ $params->{ 'details' } }; + my @keys = @{ $params->{ 'keys' } }; + + open_asm($outfile); + + # TODO better random number generator? + srand(0); + + print STDOUT "Generating code using patterns: @keys...\n"; + progress_start(78, $numinsns); + + if (grep { defined($insn_details{$_}->{blocks}->{"memory"}) } @keys) { + write_memblock_setup(); + } + + # memblock setup doesn't clean its registers, so this must come afterwards. + write_random_register_data($fp_enabled, $fsr); + + for my $i (1..$numinsns) { + my $insn_enc = $keys[int rand (@keys)]; + gen_one_insn($insn_details{$insn_enc}); + write_risuop($OP_COMPARE); + # Rewrite the registers periodically. + if ($periodic_reg_random && ($i % 100) == 0) { + write_random_register_data($fp_enabled, $fsr); + } + progress_update($i); + } + write_risuop($OP_TESTEND); + progress_end(); + + close_asm(); + assemble_and_link($outfile, $params->{ 'cross_prefix' }, + $params->{ 'keep' }, "-Av9a"); +} + +1; From patchwork Wed May 22 03:44:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 798144 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:92:b0:351:d90a:5487 with SMTP id m18csp277055wrx; Tue, 21 May 2024 20:45:36 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXu430rVImgjsYmG9DAfZEGRhYQUCGf7u0pkuVkafCV0b6LT/ftvBCB1sKYtku68AXzWpxwCCYLyspbE0Eqx5Lr X-Google-Smtp-Source: AGHT+IF7hTiY3pbv/ByFHXphMMDpJa+Nu+u7jEv1sM9FDYRRXaEdtoqW20VjxwIXZN/ljKMHevjl X-Received: by 2002:ac8:57d2:0:b0:43a:d3e6:3ecb with SMTP id d75a77b69052e-43f9e0b6562mr9622091cf.26.1716349535918; Tue, 21 May 2024 20:45:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1716349535; cv=none; d=google.com; s=arc-20160816; b=cVgILiofZW3y2gMOVWuhu0UaV30HCRlFIGgknUf5mHvGK0BnYYqVQc0rTCL4xEGe/Y baFZvayG6giPIuwfGzmkgxEsZahLW96MQieh93TpasRkYOw+q5hJh4JiGBzxshotxQHu xpnQtpCQVk9gDK4aWmMBWt9XQwGizYuVfS4Fv8R1UFE/nSc8yXDRRGviFZxDWDK7i9oX rbhif37/xvMDIOG+9CPfFC31kix03oBj76o0OUIvU2xda79NBmZq7AkB3bCMhn1Udp1t XkIgu25GXNNi7lj44HS7EG8cllzyHkdqk0qrY6oOzRJ6B8iE50zL82VHrTh69LqTTAd8 TxzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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:cc:to :from:dkim-signature; bh=PbgTPq0sjha5eVItxW9gUyB/eZqIzKak4Z6cwH63+pw=; fh=aRZTpPWhHXk/ANUEh7k3oMs8V5C8zTe7pkcDFIBzjKg=; b=0GOvHjMt1JWUBT3NOAjMs5feH54ji+KUE1IS1SgUlVwsX3DRZda0MdG1JZZys176HB AAcaC4LV5W+7QDMCVD/SA729hlGEfrzuo86inh6AyDHRCZl/cdDsuj2JncmbvgoKKkHs n9gk+TUvPYyLZ1+a/K82zFJvloG1RVw7f4GG3cn+1fQOHdPXpAqmAg/tCV/Tl5KdW2Is EmvXyTER0zzX6n17F6Wi5VIVmci8+OLtN56MTqTVVFiaVm6a/QI+2FW1C/d4mhz+F2Qq tsvODRK9ybXft0JZmNGPaxR+kslpCdtBQqpkF7nyJgVaUfMCElrur4beNlOfKqLppAtl h4dA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Y9cx/qhN"; 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=pass (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 d75a77b69052e-43dfe0a5e27si44079831cf.420.2024.05.21.20.45.35 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 21 May 2024 20:45:35 -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=pass header.i=@linaro.org header.s=google header.b="Y9cx/qhN"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s9cuR-0003WR-7t; Tue, 21 May 2024 23:44:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s9cuP-0003VY-5s for qemu-devel@nongnu.org; Tue, 21 May 2024 23:44:57 -0400 Received: from mail-pf1-x432.google.com ([2607:f8b0:4864:20::432]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s9cuK-0004C7-3t for qemu-devel@nongnu.org; Tue, 21 May 2024 23:44:53 -0400 Received: by mail-pf1-x432.google.com with SMTP id d2e1a72fcca58-6f44b390d5fso907460b3a.3 for ; Tue, 21 May 2024 20:44:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1716349490; x=1716954290; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=PbgTPq0sjha5eVItxW9gUyB/eZqIzKak4Z6cwH63+pw=; b=Y9cx/qhNCxcJ2OdrsX//4YNIxBHMI5fRX33AfuezSFSSSvrfeji2va/b2/3xEQG+P3 Z9cBy09jcP0Wn3lk/eiuscNPZNHqt4pIBhVMn+Sg3KIykL9zVEFEyqKZnjkr3omVlUY7 IZnkb6DYMuM276Yl61bq6xyNiHe0FGhYVw/MrYU66g8BYuIQXXl7sXpa7pDIzSLkg33M /4OBTJbJ+8QDq4qh6RLrxTk/1dL0EZP02anwl4TiQk6/k2+XTWEATlVkD/w/i5a03P64 ikK+65Hj9bViMC2qQKeunhbrKrSK2HZPxcwOAPC7fr0CO7CmA8UmrcdcVAQgps75rLLm DDWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716349490; x=1716954290; 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:message-id:reply-to; bh=PbgTPq0sjha5eVItxW9gUyB/eZqIzKak4Z6cwH63+pw=; b=nx3UKWEX4TmKdmYjZ3TnPT9pRz5gLeQZUlVK0Tfj/vaK9b3IDMW7i4KqlXwKW61MBl j6PWEdwsXmNlFMwVWHo68XOsBTMe75VDVY4330JBfn/hMir/MRb+3tLREM3Wmhr6V1wB SQATnVrkwyMmLyAhg3Eh66CiUj/9zyEMntb3cWamM2QUk4i05LBYf9zct46r5X8R9Hs8 AT16JDmCcMnL8jtZ1xr7vwj2fu7MdSYAWZj5NhDzVB+YCfR66+MMqinlKPZwC+tcb3Aw eCcAx9lXM3BY0WV3qHJmEJOvXFZKTy4kXlx9VZ0SH1jW4+mA6M07nYp3WIvHR95zDYAh ofOw== X-Gm-Message-State: AOJu0YzCT/169ICu6qc4GRxQYdw2MTBrybtlJ1CnGILXK7MuMXTL2wGm ePZr8rqXxEwxhzjRbTRlC2RBzN+UyjyUzcUB5K5pHIwle+oAKhdN0QCKtlz9mpjMzETgi3ab5fa l X-Received: by 2002:a05:6a00:2396:b0:6ec:fa34:34b6 with SMTP id d2e1a72fcca58-6f6d6054bf1mr817025b3a.13.1716349490112; Tue, 21 May 2024 20:44:50 -0700 (PDT) Received: from stoup.. (174-21-72-5.tukw.qwest.net. [174.21.72.5]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-6f4d2af2bafsm21416617b3a.162.2024.05.21.20.44.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 May 2024 20:44:49 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, mark.cave-ayland@ilande.co.uk Subject: [PATCH RISU v2 7/8] sparc64: Add a few logical insns Date: Tue, 21 May 2024 20:44:41 -0700 Message-Id: <20240522034442.140293-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240522034442.140293-1-richard.henderson@linaro.org> References: <20240522034442.140293-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::432; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x432.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=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Just a token to verify the script is working. Signed-off-by: Richard Henderson --- sparc64.risu | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 sparc64.risu diff --git a/sparc64.risu b/sparc64.risu new file mode 100644 index 0000000..b45ea86 --- /dev/null +++ b/sparc64.risu @@ -0,0 +1,30 @@ +############################################################################### +# Copyright (c) 2024 Linaro Limited +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +############################################################################### + +# Input file for risugen defining Sparc64 instructions +.mode sparc64 + +ADD_r SPARC 10 rd:5 0 cc:1 ci:1 000 rs1:5 0 00000000 rs2:5 \ + !constraints { reg_ok($rd) && reg_ok($rs1) && reg_ok($rs2); } +ADD_i SPARC 10 rd:5 0 cc:1 ci:1 000 rs1:5 1 imm:13 \ + !constraints { reg_ok($rd) && reg_ok($rs1); } + +AND_r SPARC 10 rd:5 0 cc:1 0001 rs1:5 0 00000000 rs2:5 \ + !constraints { reg_ok($rd) && reg_ok($rs1) && reg_ok($rs2); } +AND_i SPARC 10 rd:5 0 cc:1 0001 rs1:5 1 imm:13 \ + !constraints { reg_ok($rd) && reg_ok($rs1); } + +OR_r SPARC 10 rd:5 0 cc:1 0010 rs1:5 0 00000000 rs2:5 \ + !constraints { reg_ok($rd) && reg_ok($rs1) && reg_ok($rs2); } +OR_i SPARC 10 rd:5 0 cc:1 0010 rs1:5 1 imm:13 \ + !constraints { reg_ok($rd) && reg_ok($rs1); } + +XOR_r SPARC 10 rd:5 0 cc:1 0011 rs1:5 0 00000000 rs2:5 \ + !constraints { reg_ok($rd) && reg_ok($rs1) && reg_ok($rs2); } +XOR_i SPARC 10 rd:5 0 cc:1 0011 rs1:5 1 imm:13 \ + !constraints { reg_ok($rd) && reg_ok($rs1); } From patchwork Wed May 22 03:44:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 798145 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:92:b0:351:d90a:5487 with SMTP id m18csp277106wrx; Tue, 21 May 2024 20:45:48 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVF21Khm/hquxfFVJdC+OH9QBN+gkle+bTimOwPLPr5T8DB8/DI3NG7nlyf9jLtFysc/uCf+QzXkxJ4UQOJIKMh X-Google-Smtp-Source: AGHT+IENqMi5D9GM1I/OhO6T+q/sg5VrdG5VaYt0ncprLNpagCZ3NAlPi3nY1dNMHvI5cm/VmPYP X-Received: by 2002:ac8:5783:0:b0:43a:beea:5803 with SMTP id d75a77b69052e-43f9e17cf98mr8603871cf.50.1716349548495; Tue, 21 May 2024 20:45:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1716349548; cv=none; d=google.com; s=arc-20160816; b=CXJiFAMWPZ7gIpLHXJqnX4MLhQyb3xmndW7dF2U7MXaSjxui5Gc6ocVOyaUuctjYrP wwlO1oa+VN5u3miyLkLq2on7TaFdInz0xaMeNF9Miuv6yHZ8hX0wpRropxKpOi6RpJl9 3vQ4QEQEAuFsA8TZt95b747WTPmLL8VBYL55P6n/llcYwDEbHVxDvIQQj8B7AUHx7hX9 Phvdgd+X4Afqljq5M3hTJz9bszzSS/sm19cSLYpLKoDX0M4GP53+gFG9eSW2aSJoLjHX W1qQc4jqXW8VG+zf1P4gwvrC2AlQ+dp0B6Swlq82FS0ts+2xAd7FBcJ91R/AsxFo+7UZ N9Rg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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:cc:to :from:dkim-signature; bh=oxIUhxUvrIHw5M1h1VVAS6ldscrCFCVDcfPsbNI5LGA=; fh=aRZTpPWhHXk/ANUEh7k3oMs8V5C8zTe7pkcDFIBzjKg=; b=e3R3LnSuKGSD3+yQ26mZiraHkoBwe+c6Bw0SCSuFcEIqx9Giw1OpGymdHFMLi3f7i9 CtQVt3ctKn6r/IsIaV5Z6ofElQUGC5sfmeSqBYX9EXYMtF850xcYcvO2JSQ6HwM6fR11 DupfisZ/tOBMzIHg0cTyeX9JUx5HMdY80kBt04tYUNuQiCmtuSonCGD5/cN2r2l/1ppa 2txMjvnDNH3i59D8p7E8Hms3TNNry189tkNpi/THdOKs/HibV19ZlscH9dSZ3943nh34 N/ujjvdGnMzWL51/OX6gYECWdm6J48nexKpgMos9ImCpNuz6CLXBjAJYmqwk2pfxAlDd ENXw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vHS8pXr6; 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=pass (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 d75a77b69052e-43df549c81esi84777301cf.141.2024.05.21.20.45.48 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 21 May 2024 20:45:48 -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=pass header.i=@linaro.org header.s=google header.b=vHS8pXr6; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s9cuS-0003XJ-6n; Tue, 21 May 2024 23:45:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s9cuP-0003VZ-6T for qemu-devel@nongnu.org; Tue, 21 May 2024 23:44:57 -0400 Received: from mail-ot1-x32d.google.com ([2607:f8b0:4864:20::32d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s9cuK-0004CO-Iw for qemu-devel@nongnu.org; Tue, 21 May 2024 23:44:54 -0400 Received: by mail-ot1-x32d.google.com with SMTP id 46e09a7af769-6f0ecec6411so3258464a34.1 for ; Tue, 21 May 2024 20:44:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1716349491; x=1716954291; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=oxIUhxUvrIHw5M1h1VVAS6ldscrCFCVDcfPsbNI5LGA=; b=vHS8pXr6ugyFdAQ3hes1i0ob3vbFOOOLh3+6EZ4/EmQ2KpMvVxvtyLi4OlWrnrTHoc ZdtNSbIUiXkhqlqu2d+SjBlY02t3CyRMQqul39X0vVGTh9xabFKRklrZ41imqFm6Vj1c KVyWBTf/vDbAPJtFg0tMM/ergEVXzNtb/89QWewwniw/6XXRQ4fZ2vaTmduwIfulMvq5 /dnJrsXIWYRQ7y/utygNRHulA3Yp73NFh3FBvaWJigmg4Xm0IVB67De+DcMoj5aYXZlO MMCbCglmjL573alGmEGwGLgX4dBCC6H2nfTQR1kpi8YwFPejEwgZCmn4mxD9I6jS/dXN E6hg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716349491; x=1716954291; 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:message-id:reply-to; bh=oxIUhxUvrIHw5M1h1VVAS6ldscrCFCVDcfPsbNI5LGA=; b=YpZ8juF5r/gOsVrmLhmrETVpCCum9PkvoOYDCfxTgOvEkeFMSTWv4BFthneDlnOdP+ LlXsOcUHGA+H04nR+SpGhbsqf+bVrWKHizzEHj10QEl7D3FL4G9OKOTLDfHrtH3B2xiz 7y3frOS6xVYFUgbcVDX46V6d9fiTM9ilvadMaDTgVKi0yQ1vmiJG/SDAdMoumiykMruY kDEXVeJJTFlIBbZWM8a/vDAl9F+3HeMColTpJoGD5enqxGv/MoEgDr2IOA8f6uWntZIH 8eSn1qIXuz0v44npkEKkBPyuvMTkMNUovY/zDX4s3tzlVXTD5Mf72DOnqYYi5PvnEO9h 6ebA== X-Gm-Message-State: AOJu0Yx8EXS0k7OIuNPFpVnaLveMzXeJUI7RsjvJRRBKdULuHfnF/g+u eZ5D3z04EcrYi055mdiWrzkL7MnonunJpW9gI3zHri0e7qagGTz8FPPqXBMOAWdpYjMY1l8DZDF o X-Received: by 2002:a05:6870:6494:b0:244:bec8:febc with SMTP id 586e51a60fabf-24c68e86104mr1035918fac.56.1716349491083; Tue, 21 May 2024 20:44:51 -0700 (PDT) Received: from stoup.. (174-21-72-5.tukw.qwest.net. [174.21.72.5]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-6f4d2af2bafsm21416617b3a.162.2024.05.21.20.44.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 May 2024 20:44:50 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, mark.cave-ayland@ilande.co.uk Subject: [PATCH RISU v2 8/8] sparc64: Add VIS1 instructions Date: Tue, 21 May 2024 20:44:42 -0700 Message-Id: <20240522034442.140293-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240522034442.140293-1-richard.henderson@linaro.org> References: <20240522034442.140293-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::32d; envelope-from=richard.henderson@linaro.org; helo=mail-ot1-x32d.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=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Signed-off-by: Richard Henderson --- sparc64.risu | 91 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) diff --git a/sparc64.risu b/sparc64.risu index b45ea86..10a8510 100644 --- a/sparc64.risu +++ b/sparc64.risu @@ -28,3 +28,94 @@ XOR_r SPARC 10 rd:5 0 cc:1 0011 rs1:5 0 00000000 rs2:5 \ !constraints { reg_ok($rd) && reg_ok($rs1) && reg_ok($rs2); } XOR_i SPARC 10 rd:5 0 cc:1 0011 rs1:5 1 imm:13 \ !constraints { reg_ok($rd) && reg_ok($rs1); } + +# +# VIS1 +# + +EDGE8cc VIS1 10 rd:5 110110 rs1:5 0 0000 0000 rs2:5 \ + !constraints { reg_ok($rd) && reg_ok($rs1) && reg_ok($rs2); } +EDGE8Lcc VIS1 10 rd:5 110110 rs1:5 0 0000 0010 rs2:5 \ + !constraints { reg_ok($rd) && reg_ok($rs1) && reg_ok($rs2); } +EDGE16cc VIS1 10 rd:5 110110 rs1:5 0 0000 0100 rs2:5 \ + !constraints { reg_ok($rd) && reg_ok($rs1) && reg_ok($rs2); } +EDGE16Lcc VIS1 10 rd:5 110110 rs1:5 0 0000 0110 rs2:5 \ + !constraints { reg_ok($rd) && reg_ok($rs1) && reg_ok($rs2); } +EDGE32cc VIS1 10 rd:5 110110 rs1:5 0 0000 1000 rs2:5 \ + !constraints { reg_ok($rd) && reg_ok($rs1) && reg_ok($rs2); } +EDGE32Lcc VIS1 10 rd:5 110110 rs1:5 0 0000 1010 rs2:5 \ + !constraints { reg_ok($rd) && reg_ok($rs1) && reg_ok($rs2); } + +ARRAY8 VIS1 10 rd:5 110110 rs1:5 0 0001 0000 rs2:5 \ + !constraints { reg_ok($rd) && reg_ok($rs1) && reg_ok($rs2); } +ARRAY16 VIS1 10 rd:5 110110 rs1:5 0 0001 0010 rs2:5 \ + !constraints { reg_ok($rd) && reg_ok($rs1) && reg_ok($rs2); } +ARRAY32 VIS1 10 rd:5 110110 rs1:5 0 0001 0100 rs2:5 \ + !constraints { reg_ok($rd) && reg_ok($rs1) && reg_ok($rs2); } + +FZEROd VIS1 10 rd:5 110110 00000 0 0110 0000 00000 +FZEROs VIS1 10 rd:5 110110 00000 0 0110 0001 00000 +FONEd VIS1 10 rd:5 110110 00000 0 0110 1110 00000 +FONEs VIS1 10 rd:5 110110 00000 0 0110 1111 00000 + +FSRC1d VIS1 10 rd:5 110110 rs1:5 0 0111 0100 00000 +FSRC1s VIS1 10 rd:5 110110 rs1:5 0 0111 0101 00000 +FSRC2d VIS1 10 rd:5 110110 00000 0 0111 1000 rs2:5 +FSRC2s VIS1 10 rd:5 110110 00000 0 0111 1001 rs2:5 +FNOT1d VIS1 10 rd:5 110110 rs1:5 0 0110 1010 00000 +FNOT1s VIS1 10 rd:5 110110 rs1:5 0 0110 1011 00000 +FNOT2d VIS1 10 rd:5 110110 00000 0 0110 0110 rs2:5 +FNOT2s VIS1 10 rd:5 110110 00000 0 0110 0111 rs2:5 + +FPADD16 VIS1 10 rd:5 110110 rs1:5 0 0101 0000 rs2:5 +FPADD16s VIS1 10 rd:5 110110 rs1:5 0 0101 0001 rs2:5 +FPADD32 VIS1 10 rd:5 110110 rs1:5 0 0101 0010 rs2:5 +FPADD32s VIS1 10 rd:5 110110 rs1:5 0 0101 0011 rs2:5 +FPSUB16 VIS1 10 rd:5 110110 rs1:5 0 0101 0100 rs2:5 +FPSUB16s VIS1 10 rd:5 110110 rs1:5 0 0101 0101 rs2:5 +FPSUB32 VIS1 10 rd:5 110110 rs1:5 0 0101 0110 rs2:5 +FPSUB32s VIS1 10 rd:5 110110 rs1:5 0 0101 0111 rs2:5 + +FNORd VIS1 10 rd:5 110110 rs1:5 0 0110 0010 rs2:5 +FNORs VIS1 10 rd:5 110110 rs1:5 0 0110 0011 rs2:5 +FANDNOT1d VIS1 10 rd:5 110110 rs1:5 0 0110 0100 rs2:5 +FANDNOT1s VIS1 10 rd:5 110110 rs1:5 0 0110 0101 rs2:5 +FANDNOT2d VIS1 10 rd:5 110110 rs1:5 0 0110 1000 rs2:5 +FANDNOT2s VIS1 10 rd:5 110110 rs1:5 0 0110 1001 rs2:5 +FXORd VIS1 10 rd:5 110110 rs1:5 0 0110 1100 rs2:5 +FXORs VIS1 10 rd:5 110110 rs1:5 0 0110 1101 rs2:5 +FNANDd VIS1 10 rd:5 110110 rs1:5 0 0110 1110 rs2:5 +FNANDs VIS1 10 rd:5 110110 rs1:5 0 0110 1111 rs2:5 +FANDd VIS1 10 rd:5 110110 rs1:5 0 0111 0000 rs2:5 +FANDs VIS1 10 rd:5 110110 rs1:5 0 0111 0001 rs2:5 +FXNORd VIS1 10 rd:5 110110 rs1:5 0 0111 0010 rs2:5 +FXNORs VIS1 10 rd:5 110110 rs1:5 0 0111 0011 rs2:5 +FORNOT1d VIS1 10 rd:5 110110 rs1:5 0 0111 0110 rs2:5 +FORNOT1s VIS1 10 rd:5 110110 rs1:5 0 0111 0111 rs2:5 +FORNOT2d VIS1 10 rd:5 110110 rs1:5 0 0111 1010 rs2:5 +FORNOT2s VIS1 10 rd:5 110110 rs1:5 0 0111 1011 rs2:5 +FORd VIS1 10 rd:5 110110 rs1:5 0 0111 1100 rs2:5 +FORs VIS1 10 rd:5 110110 rs1:5 0 0111 1101 rs2:5 + +FMUL8x16 VIS1 10 rd:5 110110 rs1:5 0 0011 0001 rs2:5 +FMUL8x16AU VIS1 10 rd:5 110110 rs1:5 0 0011 0011 rs2:5 +FMUL8x16AL VIS1 10 rd:5 110110 rs1:5 0 0011 0101 rs2:5 +FMUL8SUx16 VIS1 10 rd:5 110110 rs1:5 0 0011 0110 rs2:5 +FMUL8ULx16 VIS1 10 rd:5 110110 rs1:5 0 0011 0111 rs2:5 +FMULD8SUx16 VIS1 10 rd:5 110110 rs1:5 0 0011 1000 rs2:5 +FMULD8ULx16 VIS1 10 rd:5 110110 rs1:5 0 0011 1001 rs2:5 + +FPACK32 VIS1 10 rd:5 110110 rs1:5 0 0011 1010 rs2:5 +FPACK16 VIS1 10 rd:5 110110 00000 0 0011 1011 rs2:5 +FPACKFIX VIS1 10 rd:5 110110 00000 0 0011 1101 rs2:5 +PDIST VIS1 10 rd:5 110110 rs1:5 0 0011 1110 rs2:5 + +FPMERGE VIS1 10 rd:5 110110 rs1:5 0 0100 1011 rs2:5 +FEXPAND VIS1 10 rd:5 110110 00000 0 0100 1101 rs2:5 + +# %gsr not handled by risu +# ALIGNADDR VIS1 10 rd:5 110110 rs1:5 0 0001 1000 rs2:5 \ +# !constraints { reg_ok($rd) && reg_ok($rs1) && reg_ok($rs2); } +# ALIGNADDRL VIS1 10 rd:5 110110 rs1:5 0 0001 1010 rs2:5 \ +# !constraints { reg_ok($rd) && reg_ok($rs1) && reg_ok($rs2); } +# FALIGNDATAg VIS1 10 rd:5 110110 rs1:5 0 0100 1000 rs2:5