From patchwork Mon Jun 11 17:10:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 138262 Delivered-To: patches@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp4300825lji; Mon, 11 Jun 2018 10:10:11 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJWzJhMM6SVl9py+d3fypSlt9YmEwgpdv4mmW1tViaIw9gcLXMoBnk1fO3oPOXEuVOyY5tj X-Received: by 2002:adf:9924:: with SMTP id x33-v6mr18179wrb.29.1528737010936; Mon, 11 Jun 2018 10:10:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528737010; cv=none; d=google.com; s=arc-20160816; b=IOXo4j0UAAyTPwx/w4SaR4dw478VIfabjeWidUYz3HoKTjzmneLJC/PE7rkczN32Oy Mv7RJq8p9dqsbSfNNUT8nhA0c/pOzwPzaCSWS76kVs40ElyMDIY+lfStQ/HCkChCNDsD 5dn/7XdyIqLWYDrauzpt0U2CkCWJhJditX3ci9ZHeZnHdgNS2voMv0X39PCmQipXVmfY RZdEBkggFJYDzlsQ11RP75dsfoV6pRZD53CEKWYUNW5vgyz3sbcLuiCqeSjYrEA3+/sn 0IBaqaDfdQYuNWtkN5vH6aEvmpdRs35r/rG57T9w7sftcsUx8TNNvebVq9Q/ASlzTHUc eJZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:arc-authentication-results; bh=on8/JZNx03AJi5pMNQ4OAWdUL+621+ub0GIIkRFrpe4=; b=z0x4CvHW5M3F/1LIa+jOUoZI5d1bdWrOmD/W5IS78bVmXbpAJrL8y42L9Od7+1TgBB YwbU/lpr1BQn0t8nL1xXnuAvkFBHKIfnorvUA0rV7YQiI+icYVG8ktuHcm+0jT9JBfx9 cpIbUminM3pPe+6rREda1NQ+9l+gcZoGqCFuzDTosHQlqEAE1SVV5TJqbkQ6KtaAH+/C T+1Gj/3yBVM4aOWXTqz+gKxeJV4MZvUzgy5WseeF6zgKtrQmE0QgmrwPpYyectUgHFD1 M/fxFU8qnxXwX7bQmFgF7cZecgHC0nNCOzuPjDkfbdhqZBXSnHiCTEUbTC9WzH8DgKup 9FaQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) smtp.mailfrom=pm215@archaic.org.uk; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by mx.google.com with ESMTPS id j197-v6si6215022wmj.130.2018.06.11.10.10.10 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 11 Jun 2018 10:10:10 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) client-ip=2001:8b0:1d0::2; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) smtp.mailfrom=pm215@archaic.org.uk; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1fSQKW-0007EJ-UM; Mon, 11 Jun 2018 18:10:08 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, Richard Henderson , Paolo Bonzini Subject: [PATCH 0/3] Add ldn_*_p() and stn_*_p() and use them in exec.c Date: Mon, 11 Jun 2018 18:10:04 +0100 Message-Id: <20180611171007.4165-1-peter.maydell@linaro.org> X-Mailer: git-send-email 2.17.1 There's a common pattern in QEMU where a function needs to perform a data load or store of an N byte integer in a particular endianness. At the moment this is handled by doing a switch() on the size and calling the appropriate ld*_p or st*_p function for each size. This patchset provides a new family of functions ldn_*_p() and stn_*_p() which take the size as an argument and do the switch() themselves, and uses them in 5 callsites in exec.c. If people like the idea, naming convention, etc, we can look for and convert other callsites, extend this to eg an address_space_ldn() and address_space_stn() (sample use cases in watch_mem_read(), watch_mem_write(), dino_chip_write_with_attrs(), tx_ppc_read(), tx_ppc_write()...) Patch 2 here fixes an apparently unintentional sign-extension in subpage_read(), so that patch 3 is a no-behaviour-change patch. thanks -- PMM Peter Maydell (3): bswap: Add new stn_*_p() and ldn_*_p() memory access functions exec.c: Don't accidentally sign-extend 4-byte loads in subpage_read() exec.c: Use stn_p() and ldn_p() instead of explicit switches include/exec/cpu-all.h | 4 ++ include/qemu/bswap.h | 52 +++++++++++++++++ exec.c | 112 +++--------------------------------- docs/devel/loads-stores.rst | 15 +++++ 4 files changed, 79 insertions(+), 104 deletions(-) -- 2.17.1