From patchwork Tue Sep 3 16:08:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 172848 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp87269ily; Tue, 3 Sep 2019 09:34:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqzYzBfyoWjqNnKAyqXW9D41zt2uz7xBgkasy8VHDPyJv5asscsIQ+bpRAzay5LlniPL7Ut3 X-Received: by 2002:a17:906:2f0d:: with SMTP id v13mr28538869eji.99.1567528458145; Tue, 03 Sep 2019 09:34:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567528458; cv=none; d=google.com; s=arc-20160816; b=YAjusWhaOYHgEAQq0npZb2sWvyY7cRybD+wp2MOS5ROJrsyz5JzqkPnKCuPQrFcCaH xq/nBDglEzf8VQo09acix2lhiw6gw/nBnNCSThHlGVVX6Abcl0vMM6wwuDlU2zEN0Uvl /RJrAJDebWEBDd/DBS6NKb5P7F3WcwpbHa1yYHoUTSHByvHHxJyUX61/XqxsFIuoSq9L iyxADsdyC+e5YH3uYYi8PYNXwbeuk+VxVFiVLU5pLRJs99/KvkawezAtf0rIa25l6mto 1Cl9J7DOexeCMiVKuy2tofppihrBHLn33u542c33/FfNylOzhs3U60676TkfCOBXIrSt m6aA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=UDEsommlp5Tab22dPIHKjp2gMshSz3MUBWQaZCgvboo=; b=iaghty75ZI3h6QHJ/RHfa67ono3w+XQzQhVAsATfy0CnAorkUcUjAhFnwAXiaB9zGZ hSNAgD7f7qTgDEkAY2iPV3sVydjT96ESRiOM0CLeCgMlqtJP8MgfwBy6wntoBmNVxaI+ OUTm9uw5eMSndo+wtpz3X2iw5KYtaou7L8m6/z0YIQz4y5k1vM+9nucu4DaNz5ZJlk3d /X5DlRP6EBvjwg19L0tD399gUd7Ei47IqsbOp/k/KdV4r/MUy6OUYBm/xX9fH6+j1U9D M3Eagf6nUHcZ1+kJPNWmsGJ/7wIslr4HtALtaBBJ2QZueM8Bqulvxjybq8I59BkQtNJ+ SfqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=wMxYU2TV; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id y50si9836098edb.108.2019.09.03.09.34.18 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 03 Sep 2019 09:34:18 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=wMxYU2TV; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:49020 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5Bl2-0002s3-Pf for patch@linaro.org; Tue, 03 Sep 2019 12:34:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37315) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i5BN2-0001NG-O7 for qemu-devel@nongnu.org; Tue, 03 Sep 2019 12:09:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i5BMx-0003nH-NK for qemu-devel@nongnu.org; Tue, 03 Sep 2019 12:09:28 -0400 Received: from mail-pf1-x442.google.com ([2607:f8b0:4864:20::442]:33807) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i5BMx-0003mh-At for qemu-devel@nongnu.org; Tue, 03 Sep 2019 12:09:23 -0400 Received: by mail-pf1-x442.google.com with SMTP id b24so11104664pfp.1 for ; Tue, 03 Sep 2019 09:09:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=UDEsommlp5Tab22dPIHKjp2gMshSz3MUBWQaZCgvboo=; b=wMxYU2TVR+/N+cFAu+ZWfu2EiT+FNcmCP/29gZwhHxnnvJvOCLfsD14sZS1D7oSwR8 tOpF2N/OL25vantNPfPbD/O7CwLsdAGmRpwJQwQXvF7YnzviP6OQtxNfolKhDDl3BuWZ +IxP3YR8lcjewgb4u4NsNnyrrRheonZJGM0NhkvLJ/BHZ7k9F/BjKT9RZu+uA+0V7/W5 NnK+eYfsHtJI0rb2V1DFXW0FGcViDTqeQD3FPWUUdf055C+ywoCfVpmTfyci5W1g0AVl Invud/P0O/XLOSMSGUJ570JNDXlyEpCvOl60hF31WE98gRG11NYeZp5fvwzKCeQwXfha G/4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=UDEsommlp5Tab22dPIHKjp2gMshSz3MUBWQaZCgvboo=; b=YE1bQ8+aGF9ywt+L9ruPhFeuF036jzDtly9p4Z9J79T2jm8qkq9l3pVCC/XltTPpDf ZzyCuvS5/1aNLS+zEJLmlJ8gea0DiJJz2ChyxoCh962HJgMb9wvCjBsCU54tO+ZE6/w7 QIpR1h1mUC9dtVCrGx7KaGU71LOv4RgaBgl666pMJSqazJozkylfz9uJaJ3SDid7/cQq EtbzMxzQAdHtTI5upjpeKctsPTgIzJQ+Wb1DfF5iSG3NPBtX0sbL4nv+6MAXVb2OOAq1 +wMisJu3p9AUQKf+l2UzLeTuJ/9Ktex/36XDvJQg/rpk3etrXNyxrO8kn+uH5SiKn1dr Cnvg== X-Gm-Message-State: APjAAAXHo+1pgdVqdfbuY6vTZUFTXhhVhjMwPwOtThfmx4xIicYRibkL UdyoNE+l12lBfVL4lnkI7sdiHd5Noak= X-Received: by 2002:aa7:98d2:: with SMTP id e18mr3764639pfm.188.1567526962121; Tue, 03 Sep 2019 09:09:22 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id 127sm28089711pfy.56.2019.09.03.09.09.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Sep 2019 09:09:21 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 3 Sep 2019 09:08:39 -0700 Message-Id: <20190903160858.5296-18-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190903160858.5296-1-richard.henderson@linaro.org> References: <20190903160858.5296-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::442 Subject: [Qemu-devel] [PATCH 17/36] cputlb: Byte swap memory transaction attribute X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, Tony Nguyen Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Tony Nguyen Notice new attribute, byte swap, and force the transaction through the memory slow path. Required by architectures that can invert endianness of memory transaction, e.g. SPARC64 has the Invert Endian TTE bit. Suggested-by: Richard Henderson Signed-off-by: Tony Nguyen Reviewed-by: Richard Henderson Message-Id: <2a10a1f1c00a894af1212c8f68ef09c2966023c1.1566466906.git.tony.nguyen@bt.com> Signed-off-by: Richard Henderson --- include/exec/memattrs.h | 2 ++ accel/tcg/cputlb.c | 12 ++++++++++++ 2 files changed, 14 insertions(+) -- 2.17.1 diff --git a/include/exec/memattrs.h b/include/exec/memattrs.h index d4a3477d71..95f2d20d55 100644 --- a/include/exec/memattrs.h +++ b/include/exec/memattrs.h @@ -37,6 +37,8 @@ typedef struct MemTxAttrs { unsigned int user:1; /* Requester ID (for MSI for example) */ unsigned int requester_id:16; + /* Invert endianness for this page */ + unsigned int byte_swap:1; /* * The following are target-specific page-table bits. These are not * related to actual memory transactions at all. However, this structure diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c index 3c9e634d99..d9787cc893 100644 --- a/accel/tcg/cputlb.c +++ b/accel/tcg/cputlb.c @@ -738,6 +738,10 @@ void tlb_set_page_with_attrs(CPUState *cpu, target_ulong vaddr, */ address |= TLB_RECHECK; } + if (attrs.byte_swap) { + /* Force the access through the I/O slow path. */ + address |= TLB_MMIO; + } if (!memory_region_is_ram(section->mr) && !memory_region_is_romd(section->mr)) { /* IO memory case */ @@ -891,6 +895,10 @@ static uint64_t io_readx(CPUArchState *env, CPUIOTLBEntry *iotlbentry, bool locked = false; MemTxResult r; + if (iotlbentry->attrs.byte_swap) { + op ^= MO_BSWAP; + } + section = iotlb_to_section(cpu, iotlbentry->addr, iotlbentry->attrs); mr = section->mr; mr_offset = (iotlbentry->addr & TARGET_PAGE_MASK) + addr; @@ -933,6 +941,10 @@ static void io_writex(CPUArchState *env, CPUIOTLBEntry *iotlbentry, bool locked = false; MemTxResult r; + if (iotlbentry->attrs.byte_swap) { + op ^= MO_BSWAP; + } + section = iotlb_to_section(cpu, iotlbentry->addr, iotlbentry->attrs); mr = section->mr; mr_offset = (iotlbentry->addr & TARGET_PAGE_MASK) + addr;