<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Om Narasimhan on Medium]]></title>
        <description><![CDATA[Stories by Om Narasimhan on Medium]]></description>
        <link>https://medium.com/@om.nara?source=rss-de8ac1f5583c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*mHybkBvAy9mi7rFm</url>
            <title>Stories by Om Narasimhan on Medium</title>
            <link>https://medium.com/@om.nara?source=rss-de8ac1f5583c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 20:52:23 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@om.nara/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[PERST# debug: an example]]></title>
            <link>https://medium.com/@om.nara/perst-debug-an-example-e4d766adb739?source=rss-de8ac1f5583c------2</link>
            <guid isPermaLink="false">https://medium.com/p/e4d766adb739</guid>
            <dc:creator><![CDATA[Om Narasimhan]]></dc:creator>
            <pubDate>Sat, 12 Sep 2026 20:38:14 GMT</pubDate>
            <atom:updated>2026-11-23T00:11:54.542Z</atom:updated>
            <content:encoded><![CDATA[<p>Now that we have a clear understanding about how PERST#’s routing on an AIC board as well as an SoC, let us examine some design ideas on SoCs and AIC boards with reference to PERST#</p><p>Please read the first two part of this series here</p><ul><li><a href="https://medium.com/@om.nara/perst-and-ep-soc-131d5ee8bedf">PERST# and EP SoC</a></li><li><a href="https://medium.com/@om.nara/a-deep-dive-into-perst-the-signal-that-decides-whether-your-pcie-link-ever-trains-85be3f179118">A deep dive into PERST# — The Signal That Decides Whether Your PCIe Link Ever Trains</a></li></ul><h3>PERST# and SoC Design</h3><ul><li>Method to trigger an interrupt at PERST# state change: An interrrupt mechanism that can indicate PERST# state changes (assertion and deassertion) is very useful for accurate handling of required firmware actions</li><li>Register to read the current value and state changes of PERST#: Pulse width of PERST# is hugely variable (100us minimum, no maximum), it is very helpful for the firmware to read the state changes that caused the interrupt as well as the current state of PERST#</li><li>Timer: A timer is very helpful to make sure the EP meets various timing requirements imposed by the PCIe specification</li><li>Programmable APB/DBI/DBI2 register access timeouts: Very helpful in debugging some delayed responses and bus hangs while accessing registers in these domains.</li></ul><h4>PERST# and PCIe Controller and PHY regiser access: A caveat</h4><p>Depending on the power, clock, and reset domain, some registers may not be accessible during the time PERST# is asserted. Worse yet, some registers are readable (reads reset values) but silently discards the written value. SoC designers are strongly recommended to document the correct register file behavior so that firmware access won’t cause surprises later during bring-up phase.</p><h4>Boot Island</h4><p>If the SoC is targeted at AIC designs, to meet the AIC timing specification WRT PERST#, the EP LTSSM must enter Detect within 20 ms of PERST# deassertion. Since PERST# can deassert as early as 100 ms after power is stable, that leaves roughly 120 ms from power-good in the worst case. This is a very tight timeline to meet for an SoC that has to do LBIST/MBIST as a part of hardware initialization. Please consider a small boot island with minimal subsystems if you are targetting such markets.</p><h3>PERST# and AIC board design</h3><h4>Connecting PERST# to board reset</h4><p>For the ease of software implementation a few board designs features PERST# triggering a board reset. This is a BAD design on multiple counts</p><ul><li>Potential failure to meet specification timing: As described in the previous part of this series, the EP’s LTSSM should enter Detect state within 20ms of PERST#’s deassertion. Your AIC SoC needs to run its initializations within this time frame and get the PHY</li><li>Software state management: PERST# assertion being truly asynchronous, if tied to board reset, can introduce surprise power downs on the AIC. Depending on the software design this can cause major troubles.</li><li>Although specifications do not mandate it, it is logical to expect PERST# by virtue of bing a signal confined to PCIe domain, to leave out other components and subsystems in the AIC which are unrelated to PCIe.</li></ul><h4>PERST# Delay circuit on board</h4><p>The spec guarantees a minimum of 100us between stable REFCLK to PERST# deassert. But, if your clock generator (or parts of clock tree) requires more time than that to produce stable clock outputs, a small (often configurable) delay circuit may be introduced. This could help you in avoiding very weird situations like the PHY behaving badly when its brought out of reset without a stable clock … and other very hard to debug component/IP behaviors.</p><h4>PERST# status on board</h4><p>If your SoC does not provide a method to generate interrupts (as described previously), it would be a good option to connect PERST# to a GPIO pin that can be configured as an input which can be read by firmware determine the PERST# state. This pin can be configured as an interrupt in the GPIO block, but may entail a few problems because:</p><ul><li>Firmware needs to determine when PERST# is asserted so that the accesses to register files across different reset/power domains can be facilitated</li><li>Firmware needs to determine when PERST# is deasserted so that it can program the required components and meet the strict timelines required by the specification</li></ul><p>An interrupt source, with the facility to read the current value would be the ideal solution. Otherwise, a polling routine set up at sub-millisecond interval would be sufficient.</p><h3>PERST# and Firmware Design</h3><p>The following table lists various initializations the system firmware executes that are typically associated with different types of host’s booting</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SKGfVfdROlabdPKFGnsS8w.png" /><figcaption>Actions executed by a typical AIC firmware</figcaption></figure><p>DDR initialization (due to large configuration and training time) and non-essential non-pcie subsystems (ethernet, USB, SPI, I2C/I3C, …etc) are not carried out before the PCIe initailization. Such actions are executed out by either Secondary Boot Loader or the system firmware <em>after</em> PCIe EP init is complete.</p><h3>A real-world example</h3><p>This section describes the problems the author and team faced while debugging a knotty problem: The Gen5 AIC failed to link up on several server platforms (Intel, AMD, ARM64) during interoperability testing. After the fixes described below, it interoperates with 9 of the 10 platforms tested. The symptoms were varied — some failed to link up, some showed non-standard device ID/vendor id, some intermittently failed, and some other behaved differently across cold and warm boot cycles.</p><p>The SoC featured a well known IP vendor’s PCIe core configured as EP(by firmware, not strapped) and PHY with the following characteristics:</p><ul><li>No in-IP logic to determine the current PERST# state</li><li>No custom glue logic to determine the current PERST# state</li><li>Controller registers were readable and returned the reset values during PERST# assert</li><li>Controller registers silently discarded DBI2 writes during PERST# assert</li><li>PHY registers were not readable and caused timeout when APB registers were programmed or caused indefenite delay till PERST# deassert and PCLK stabilized</li><li>Could generate an interrupt during link down (and PERST# assert caused a link down event) with a sticky interrupt status register readable during PERST# assert</li></ul><p>The AIC design was supposed to connect PERST# to a GPIO pin, but this requirement was missed out from the board design and was not noticed until it was too late!</p><h4>Attempt 1: Tie board reset signal to PERST</h4><p>As described previously, this was BAD! This worked well in theory, but caused a significant number of unrelated software errors due to flash corruption. Trying to change the file system to more robust ones with journaling did not help much, just delayed the problems. Trying to run the root FS from memory was not feasible as the application required every byte of memory that can be made available, especially with the high cost of DDR now!</p><p>The most unexpected side effect was that the EP failed the timing requirement during the PCIe certification. It took about 20ms for the power rails to stabilize after board reset was deasserted. The EP’s LTSSM entered Detect about 68 ms after PERST# deassertion, more than three times the 20 ms limit!</p><h4>Attempt2: Separated PERST and chip resets, Interrupt on Link down event</h4><p>Since the IP used could generate an interrupt on a link down event (technically two: One for LDE and one for surprise LDE), an interrupt handler was installed for serving both LDEs. The handler reads DID/VID register via DBI (for want of any better method). If read the reset values (that of the vendor), it conveyed to the software that a PERST occurred. This register was safe to access via DBI as long as the core_clk was active and stable. So, after checking the SoC clock tree and making sure that core_clk is driven by an independent clock source, this implementation was tried.</p><h4>Ordinary link downs</h4><p>During normal opeations, the link down event can be triggered by secondary bus reset from the downstream port, hot resets or normal link down events. These events do not cause the reset of the core and can be differentiated from PERST# assertion by reading DID/VID register contents.</p><h4>SBR and Hot Reset</h4><p>Secondary Bus Reset uses Hot Reset to signal the reset and releases hot reset when directed by software on the host. Hot reset causes TS1s with hot reset bit set. The LTSSM leaves the current state (L0) and enter hot reset state for at least 2ms (or till the end of hot reset in case of software triggered SBR) before exiting to Recover state.</p><p>Hot reset causes the LDE but not a PERST# event. In addition to LDE, hot reset causes a hot reset interrupt to the upper layer application and is handled gracefully.</p><h4>Failures of this approach</h4><p>1. LDE triggers the interrupt handler that infers PERST assertion. But, it is critical to determine if the PERST deassertion. If not, the controller programming during PERST assert would be discarded silently by the PCIe core because the asserted PERST# kept the controller in reset</p><p>In order to handle this case, the interrupt handler started a poll routine to infer the PERST# deassert. The poll routine scheduled for 250us interval programmed DID/VID register once and read it back. During PERST# assert, the programmed values were lost and reset values were read. Once the read values matdched the programmed values, PERST# deassert was inferred.</p><p>2. During interop/Compatibility testing we discovered that there are a few servers that issued multiple PERST# assertions during cold boot. This situation exposed a fatal shortcoming in the logic implemented.</p><p>During the cold boot, the firmware in the EP determines the PERST deassertion and programs the configuation space, PHY, and other components before installing the LDE interrupt handler. But, when the second PERST assertion by the host comes in, the LDE event does not occur because the link has never been established! Link down event happens only after the link has been up at least once. During the cold boot, RC’s LTSSM enters active state only after the second PERST# assertion.</p><h4>Attempt3: Moving to polling</h4><p>Since we cannot depend on LDEs during the host boot up state, using a timer interrupt, we implemented a FSM with three states. During cold boot, the FSM would stay in INIT state and infer the PERST# state once every 500us. First run after PERST# deassert, FSM advances to PROGRAMMED state and continue in it. FSM progresses to OPERATIONAL state once the actual link up event occurs. A PERST assert in any state would take the FSM to INIT. An ordinary link down event (or hot-reset/SBR) would cause the FSM to enter PROGRAMMED state and wait for link up event.</p><h4>Inferring PERST# state: A few other approches</h4><h4>Using Receiver detect to check the end of PERST#</h4><p>The idea behind this bitfield is that, once LTSSM enters the Dectect.Active state, it would execute the Electrical Detection procedure and find if a link partner exists. This method turned out to be unreliable in some platforms. There are a few problems associated with this approach.</p><ol><li>This method won’t work for some PHYs that require the firmware loaded and running for the LTSSM functionality.</li><li>Accessing PHY registers while PERST# is asserted (and PCLK is not preset/unstable) can stall. You may have to reprogram APB timeout value and check for APB errors to infer PERST#, thus nullifying this approach.</li><li>During warm reboots, the host / RC’ sPHY and LTSSM may stay in Detect state. This is possibly an erroneous behavior on the RC’s PHY part, but that possibility eliminated this method as a reliable mechanism.</li></ol><h4>Using IP specific register PCIEn_LINK_DBG_2::cdm_in_reset</h4><p>This register bit shows if the CDM is in reset. Whenever the controller state changes to reset (including PERST# assertion), this bit would be 1. Once PERST# is deasserted and the controller gets out of reset, will change to 0. This bit is readable irrespective of PERST and can be used as an indicator if you want to avoid read/write cycles to VID/DID register.</p><p>During SBR/Hot Reset, this bit gets asserted even when PERST# remain deasserted. So, additional checks are required to infer correct state of PERST#</p><p>-End.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e4d766adb739" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[PERST# and EP SoC]]></title>
            <link>https://medium.com/@om.nara/perst-and-ep-soc-131d5ee8bedf?source=rss-de8ac1f5583c------2</link>
            <guid isPermaLink="false">https://medium.com/p/131d5ee8bedf</guid>
            <dc:creator><![CDATA[Om Narasimhan]]></dc:creator>
            <pubDate>Sun, 30 Aug 2026 21:27:01 GMT</pubDate>
            <atom:updated>2026-11-23T00:12:47.243Z</atom:updated>
            <content:encoded><![CDATA[<p>In this second part of the PERST# deep dive, we delve deep into the propagation of PERST# from the edge of the AIC all the way to SoC. We also try to draw a detailed picture of how PERST# affects each component of the AIC.</p><p>You can find the first part of this series here</p><p><a href="https://medium.com/@om.nara/a-deep-dive-into-perst-the-signal-that-decides-whether-your-pcie-link-ever-trains-85be3f179118">A deep dive into PERST# — The Signal That Decides Whether Your PCIe Link Ever Trains</a></p><h3>PERST#: Board-Level Connection Routing</h3><p>For an AIC (or a board-to-board embedded link), PERST# has to physically traverse the card edge connector, board traces, potential voltage domains, and any role-selection logic before it reaches the SoC pin. Key elements are:</p><ul><li><strong>Gold fingers (card edge connector)</strong>: On a CEM AIC, PERST# is a dedicated pin on the card edge connector that is at a defined position per the CEM mechanical spec. This is always driven from the host/slot side into the card, and is always an input for the card-side PHY and controller.</li><li><strong>Voltage translators</strong>: PERST# on the CEM connector is specified at a 3.3V-tolerant logic level. Many modern SoCs run their GPIO/IO rings at 1.8V or lower for the relevant bank. Any board that bridges a 3.3V CEM-defined PERST# net to a lower-voltage SoC pin needs a level translator in the path. Omitting this detail is a classic cause of intermittent PERST# sensing failures or, worse, IO reliability issues from over-voltage stress on an SoC pad not rated for 3.3V.</li><li><strong>MUX to GPIO for dual role (EP/RC) support</strong>: Where the SoC’s PCIe controller/PHY can operate as either an endpoint or a root complex depending on product configuration, the PERST# pin’s direction requirement flips (input when acting as EP, output when acting as RC driving a downstream device). Board designers handle this either with an actual analog mux/switch selecting the net’s source, or — more commonly in modern SoCs — by muxing the function at the SoC pin level (pinmux selecting GPIO output mode vs. dedicated PERST-input mode) and using a resistor/no-populate strategy on the board to define which mode is stuffed for a given board variant.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9CmvUjNqPHhuV05ZiRreSw.png" /><figcaption><em>PERST# signal flow path on an EP AIC</em></figcaption></figure><h4>Points to consider during AIC board design</h4><p>Connecting PERST# to board reset</p><p>For the ease of software implementation a few board designs features PERST# to trigger a board reset. This is a BAD design on multiple counts</p><ul><li>Potential failure to meet specification timing: As described in the previous part of this series, the EP’s LTSSM should enter Detect state within 20ms of PERST#’s deassertion. Your AIC SoC needs to run its initializations within this time frame and get the PHY</li><li>Software state management: PERST# assertion being truly asynchronous, if tied to board reset, can introduce surprise power downs on the AIC. Depending on the software design this can cause major troubles</li></ul><h4>PERST# Delay circuit on board</h4><p>The spec guarantees a minimum of 100us between stable REFCLK to PERST# deassert. But, if your clock generator and tree requires more time than that to produce stable clock outputs, a small (often configurable) delay circuit may be introduced. This could help you in avoiding very weird situations like the PHY behaving badly when its brought out of reset without a stable clock … and other very hard to debug component/IP behaviors.</p><h3>PERST#: On-SoC Connection Routing</h3><p>Inside the SoC, PERST# (or its internal GPIO-muxed equivalent) has to be distributed from the pad, through pinmux and pad-strength configuration, into the correct reset domains feeding the PHY and controller, all while respecting the SoC’s broader power-domain and reset-domain architecture.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5UoJFQThW2sM3CCdzPSn-A.png" /><figcaption><em>Typical routing of PCIE EP Data/Control paths and PERST# in an SoC</em></figcaption></figure><ul><li><strong>SoC PinMUX:</strong> Even when the board doesn’t do external role selection, the SoC pinmux itself typically must select whether a given pad functions as a dedicated PERST# input, a general-purpose GPIO (driven as PERST# output in RC mode), or another alternate function entirely — this is standard SoC pad-mux configuration, set by boot firmware/fused configuration before the PCIe subsystem is brought out of reset.</li><li><strong>Routing to the PHY</strong>: Internally, PERST# (post-synchronization) is typically distributed as a low-skew reset tree directly to the PHY’s reset pins (per-lane SerDes reset and PLL reset) as well as to the MAC/controller reset input, often with local reset synchronizer flops in each destination clock domain to convert the asynchronous PERST# assertion into a clean synchronous release in that domain’s clock.</li><li><strong>Reset domains and power planes</strong>: This is where PERST#’s system-level significance really shows up in SoC power architecture. PERST# sensing logic is frequently placed in an <strong>always-on (AON) power domain</strong>, so the SoC can detect and respond to PERST# assertion/deassertion even if the main PCIe/core power domain is power-gated for low-power states — this matters for platforms that power down the PCIe PHY/controller during suspend but still need to observe PERST# transitions to know when to re-power and re-initialize. Correspondingly, the PCIe subsystem often spans multiple power planes (VDD_AON for reset/wake sensing, VDD_CORE for digital MAC logic, VDD_PHY/VDDA for the analog SerDes), and the reset architecture has to guarantee that PERST#-driven resets are asserted and held correctly across all of these planes’ power-up sequencing — i.e., the digital core reset must not release before its power plane is stable, and the PHY analog reset must not release before its own (often separately sequenced) analog supply and REFCLK are valid, even though all of it is ultimately gated by the same external PERST# event.</li><li><strong>Drive strength control in RC mode</strong>: When the pin is configured as an output driving PERST# to a downstream device, pad drive-strength settings need to be configured to meet the downstream device’s input timing and the trace’s electrical characteristics</li></ul><h3>PERST# and the EP Controller</h3><p>Inside the digital controller — the LTSSM, Data Link Layer, Transaction Layer, and configuration space block — PERST# is typically wired as (or synchronized into) the controller’s primary asynchronous reset. Architecturally this reset needs to be:</p><ul><li><strong>Asynchronous assert, synchronous deassert.</strong> PERST# can assert at any time relative to the core clock (it’s an external, asynchronous event), so the reset tree must guarantee immediate assertion regardless of clock state, while deassertion is synchronized to the core clock domain to avoid metastability on the LTSSM’s state registers.</li><li><strong>Global to the LTSSM and DLL/TL state machines.</strong> On assertion, the LTSSM is forced back to its initial detect-equivalent state, all replay buffers and DLLP sequence-number state in the Data Link Layer are cleared, and Transaction Layer credit initialization state is invalidated — the link has to fully re-establish flow control credits after the next LTSSM training sequence, exactly as it would after a cold boot.</li><li><strong>Global to configuration space</strong>, with the caveat that PCIe explicitly permits certain state to be sticky across fundamental reset if it’s powered by Vaux (auxiliary power) and the device advertises AUX_PWR support — this is the mechanism that allows PME context and some wake-related state to survive PERST# assertion in systems that keep 3.3Vaux alive during S3/S4/S5.</li></ul><p>The important nuance for a core architect: PERST# is usually not fed raw into every flop in the design. It’s brought in as a chip-level asynchronous reset, synchronized locally per clock domain (core clock, AUX clock, PIPE PCLK domain), because a modern controller has several clock domains that are not all active or valid at the same time PERST# transitions.</p><h3>PERST# and the PHY Instance</h3><p>The PHY (SerDes) is arguably more sensitive to PERST# sequencing than the digital core, because it contains analog blocks — PLLs, bias generators, receiver termination and CDR — that have real settling-time and reference-stability requirements. When PERST# is asserted:</p><ul><li>PLLs are typically held in reset/power-down, since there is no guarantee REFCLK is stable or even present.</li><li>Transmitters are forced to electrical idle (no differential signaling), which is a hard PCIe electrical requirement — an endpoint must never drive TX during PERST# assertion.</li><li>Receiver termination and detection circuits are held inactive, since receiver detect (the analog mechanism the LTSSM’s Detect state uses to sense a far-end termination) is meaningless without a stable reference and powered analog front end.</li><li>Calibration state (Tx driver impedance calibration, Rx offset calibration, etc.) is invalidated and must be re-run as part of PHY initialization after PERST# deasserts.</li></ul><p>This is why PERST# deassertion is never the moment link training begins — it’s the moment PHY initialization is <em>permitted</em> to begin. There’s a whole sequence (PLL lock, calibration, PIPE interface handshake) that must complete before the LTSSM is even allowed to leave Detect.Quiet for Detect.Active.</p><h3>PERST# and the PIPE Interface</h3><p>The PIPE (PHY Interface for PCI Express) specification defines the standardized digital boundary between the MAC/controller and the SerDes PHY, and it explicitly includes reset semantics in that boundary. PERST# (or a chip-level derivative of it, as depicted in the diagram) is generally wired to the PHY’s reset input as defined in PIPE, and its effect on the PIPE interface signals includes:</p><ul><li><strong>PCLK validity</strong>: PIPE’s parallel clock (PCLK), sourced from the PHY back to the MAC, is not guaranteed valid until PHY reset has been released and the PLL has locked. Controllers must not sample PIPE signals off an invalid PCLK.</li><li><strong>PowerDown state forcing</strong>: PIPE defines PowerDown[1:0] encodings (P0, P0s, P1, P2, and the PIPE-specific reset-adjacent states). On PERST# assertion, PowerDown is forced/expected to reflect a non-operational state, and the MAC does not attempt to transition the PHY through P0 (active) until reset is released.</li><li><strong>TxElecIdle forced active</strong>: consistent with the electrical idle requirement, TxElecIdle is held asserted so the PHY’s transmit drivers remain in idle.</li><li><strong>RxValid/PhyStatus gating</strong>: RxValid and PhyStatus outputs from the PHY are not considered meaningful while the PHY is held in reset — the MAC must not act on receiver status until after the standard PIPE initialization handshake (PhyStatus toggling to indicate PHY ready, RxElecIdle reporting valid electrical idle detection, etc.) completes post-PERST#.</li></ul><h3>PERST# and the AXI/APB</h3><p>On an SoC, the PCIe controller is a NoC-attached peripheral, typically exposing:</p><ul><li>One or more <strong>AXI (or AXI-like) master interfaces</strong> carrying the data path — inbound and outbound TLPs translated to/from AXI read/write transactions, DMA traffic, MSI/MSI-X writes, etc.</li><li>An <strong>AXI slave interface</strong> for the host/local processor to access the controller’s memory-mapped BARs or perform configuration-space-mapped accesses in RC mode.</li><li>A separate <strong>APB (or similar low-speed) control interface</strong>, used for register configuration, status/interrupt reporting, and debug access to the controller and PHY</li><li>DBI/DBI2 (via APB ↔ DBI/2 bridge) for Internal / Configuration space / shadow register access</li></ul><p>PERST#’s relationship to these interfaces is an important design decision, not an automatic consequence:</p><ul><li>The <strong>AXI data path is almost always reset by PERST#</strong> (directly or via the controller’s internal reset tree), because there is no valid TLP traffic possible while the link is down — any in-flight AXI transaction tied to link activity becomes meaningless and potentially dangerous to leave outstanding (a hung AXI transaction can stall the NoC if not fenced off).</li><li>The <strong>APB control/status interface is frequently kept out of the PERST# reset domain</strong>, or reset by a separate, narrower reset, specifically so that firmware/software can still read status and sticky registers (link state history, AER logs, PHY calibration status, error counters) <em>after</em> a PERST# event, for debug and recovery decision-making. This is a deliberate architectural split to make the control-plane register file available for analysis to determine what state things were in beforehand, even though the data-plane pipeline is being torn down.</li></ul><p>This split is one of the more subtle but important pieces of SoC-level PCIe integration: PERST# is not a single flat reset net, but one fans out into at least two or three distinct reset domains (PHY analog reset, MAC/LTSSM core reset, and AXI datapath reset).</p><p>In the next part of this series, we will discuss several issues on a production AIC which all were traced back to PERST# and some of the methods to solve/eliminate such problems.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=131d5ee8bedf" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A deep dive into PERST# — The Signal That Decides Whether Your PCIe Link Ever Trains]]></title>
            <link>https://medium.com/@om.nara/a-deep-dive-into-perst-the-signal-that-decides-whether-your-pcie-link-ever-trains-85be3f179118?source=rss-de8ac1f5583c------2</link>
            <guid isPermaLink="false">https://medium.com/p/85be3f179118</guid>
            <category><![CDATA[pci-express]]></category>
            <category><![CDATA[pci-compliance]]></category>
            <category><![CDATA[pcie]]></category>
            <category><![CDATA[board-bringup]]></category>
            <category><![CDATA[firmware]]></category>
            <dc:creator><![CDATA[Om Narasimhan]]></dc:creator>
            <pubDate>Fri, 21 Aug 2026 04:56:40 GMT</pubDate>
            <atom:updated>2026-08-21T04:56:40.327Z</atom:updated>
            <content:encoded><![CDATA[<p>Most PCIe bring-up debug efforts eventually trace back to one net: PERST#. Beginners take it as an unassuming active-low signal that is driven from the RC side to indicate it is ready for link training. As one gains more experience working with PCIe, it becomes clear that PERST#’s role is way beyond that initial take — it plays a vital role in power sequencing, clock domain design, PHY architecture, and system firmware. Getting it wrong either in the SoC design or in the board design gets you a link that trains intermittently, a device that enumerates only on cold boot, or only on a set of host machines, or a controller that hangs waiting for a PHY that never came out of reset cleanly. This is the first part of an article series that walk you through PERST# from the protocol definition down to the physical pin, aimed at engineers who already are familiar with LTSSM and configuration space, and have a fair understanding of PCIe controllers, PHYs, and the interconnects used in SoC designs as well as board designs. The author sincerely hopes that this article series would be helpful in throwing some light on the reasons behind this signal is treated with so much reverence in both the CEM specification and real SoC integration guides.</p><h3>List of PCIe resets</h3><ul><li><strong>Cold reset (or power down reset):</strong> Clears everything in the EP.</li><li><strong>Fundamental reset (via PERST#)</strong>: PERST# triggers the fundamental reset of the EP which resets almost everything in the EP — LTSSM, PHY, configuration space, and <strong>any non-sticky state </strong>information. One exception is that any state explicitly kept sticky via Vaux backed power (e.g., PME context on AUX_PWR-capable devices), which can survive PERST# assertion as long as 3.3Vaux remains applied.</li><li><strong>Warm reset:</strong> A conceptual reset applied when main power remains applied but a reset event has occurred (often overlaps with hot reset or PERST# depending on platform implementation).</li><li><strong>Function Level Reset (FLR)</strong>: A software-initiated, per-function reset via the Device Control register, scoped to a single function’s internal state, leaving the link itself intact.</li><li><strong>Hot reset</strong>: An in-band mechanism, signaled by sending TS1 ordered sets with the Hot Reset bit set. This is used to reset a downstream device without cycling power or toggling PERST# deassert.</li><li><strong>Secondary Bus Reset (SBR)</strong>: A software triggered reset mechanism to reset all devices on the secondary side of a PCIe switch. SBR uses hot reset as the mechanism of implementation.</li></ul><h3>PERST#: What It Is and Why It Exists</h3><p>PERST# (PCI Express Reset, active low) is the signal controlling the fundamental reset of the PCI Express hierarchy, defined in the PCI Express Card Electromechanical (CEM) Specification and referenced throughout the PCIe Base Specification as the mechanism that forces every downstream component into a known, deterministic state. <strong>Please note that this is not the fundamental reset signal, but one triggers the fundamental reset.</strong> It is distinct from (for PERST# is the only one of these that is a <strong>physical, sideband, asynchronous signal</strong>) every other reset mechanism listed previously. Hence its significance: it doesn’t depend on the link being trained, doesn’t depend on REFCLK being valid, and doesn’t depend on any prior protocol state. It exists specifically so that the system can guarantee a clean, known starting point regardless of what state the device or the link was previously in — including states where the LTSSM itself might be wedged.</p><p>In such contexts, PERST# needs to be treated as the synchronization boundary between the <strong>power/clock domain</strong> and the <strong>protocol domain</strong>. Nothing in the LTSSM, DLLP, or TLP layer is deemed to be valid until PERST# has been properly sequenced relative to power rails and REFCLK.</p><h3>Who Drives PERST#</h3><p>PERST# is unambiguously a <strong>Root Complex (host)-driven, downstream signal</strong>. In a conventional topology — whether that’s a CEM add-in card, an M.2 SSD, or an SoC-to-SoC embedded link — the Root Complex side (or, more precisely, the platform reset logic associated with the RC) drives PERST# to every downstream port it owns. The endpoint never drives its own PERST# input; it only observes it.</p><p>In practice, “the RC drives it” is a simplification worth unpacking for board/SoC and firmware designs, because the actual driver is rarely the PCIe controller IP itself:</p><ul><li>On a CEM-compliant motherboard, PERST# is generated by platform power sequencing logic (a PMIC, CPLD, or dedicated power sequencer) that watches the 12V/3.3V rail power-good signals and asserts/deasserts PERST# as part of the slot power sequence.</li><li>On an SoC that instantiates an embedded RC (e.g., driving a PCIe endpoint SoC), PERST# is typically a GPIO under firmware or hardware sequencer control — driven low at power-up, held low across the platform’s boot/power-good handshake, then released by boot firmware once REFCLK and rails are confirmed stable.</li><li>On multi-role SoCs that can operate as either an RC or an EP on the same physical PCIe controller (common in embedded and automotive SoCs), the PERST# pin’s direction itself is configurable — this is precisely the “MUX to GPIO” requirement discussed later: the pin needs to be an <strong>output</strong> when the SoC acts as RC and an <strong>input</strong> when the SoC acts as EP.</li></ul><h3>PERST# on a host board: one or many?</h3><p>One point worth calling out explicitly for multi-slot hosts: <strong>PERST# is always per-slot, never shared, even when the upstream rails and clock feeding those slots are shared or commonly-derived.</strong> 12V and 3.3V main power are typically sourced from common system rails but gated per slot through individual power switches; 3.3Vaux is generally a shared standby rail; and REFCLK is usually distributed from a single oscillator through a clock buffer/fanout IC into electrically separate, per-slot outputs (a “common clock” architecture), or in SRNS/SRIS designs, as fully independent per-slot oscillators. PERST#, by contrast, <strong>must be dedicated per slot</strong> and driven by dedicated platform sequencing or hot-plug controller logic, because each slot needs to be independently populatable, sequenced, and resettable without disturbing devices already running in neighboring slots — a shared PERST# line would trigger every device on it into fundamental reset whenever any one slot was hot-plugged or reset.</p><h3>RC/Host Control of the Sequence</h3><p>Because PERST# deassertion timing has a minimum but no maximum, the actual moment PERST# is released is entirely a <strong>host/platform policy decision</strong>, not a protocol-mandated one. In practice this means:</p><ul><li>On general-purpose platforms, <strong>UEFI/BIOS</strong> (or, in server platforms, the BMC/platform firmware working with UEFI) owns the PERST# sequencing as part of the broader power-on sequence — it typically holds PERST# asserted through rail power-good confirmation and REFCLK-stable confirmation, then releases it as part of PCIe root port initialization, well before OS handoff, so that by the time the OS’s PCIe enumeration runs, links are already trained (or at least eligible to train).</li><li>On embedded/SoC platforms, this role is played by <strong>boot firmware</strong> — a first-stage bootloader, a dedicated power-sequencing microcontroller, or an early boot-ROM. Secondary Boot Loader (SBL) stage — which drives the PERST# GPIO according to the platform’s documented power-up sequence, often coordinated with regulator enable signals and REFCLK source enable, before handing control to the main OS’s kernel PCIe driver stack.</li></ul><p>The practical takeaway for anyone debugging enumeration failures: if a device isn’t training reliably, the first two things to interrogate are —</p><p>(1) was PERST# actually held long enough relative to rail stability and REFCLK stability, and</p><p>(2) is the deassertion edge itself clean (no glitching from a marginal GPIO driver or a poorly-terminated long trace) — because the spec’s permissiveness on maximum timing means platform firmware bugs, not protocol ambiguity, are the usual root cause of PERST#-related bring-up issues.</p><h3>PERST#’s Role in a PCIe Endpoint</h3><p>From the endpoint’s point of view, PERST# is the master signal that holds the entire PCIe subsystem — controller, PHY, and often parts of the interconnect bridge logic — in a defined reset state while platform configures and stabilizes the electrical and clocking environment. Specifically, while PERST# is asserted, a compliant endpoint must:</p><ul><li>Hold its LTSSM in a reset-equivalent state (implementation-specific, but functionally equivalent to Detect.Quiet with all transmitters in electrical idle) — it <strong>must not</strong> attempt link training.</li><li>Tri-state or hold in electrical idle its transmit differential pairs — no signaling activity on TX until PERST# deasserts and REFCLK/PHY are confirmed valid.</li><li>Reset the entirety of its PCIe configuration space to defined default/reset values (excluding certain Vaux-backed sticky bits such as some AER/PME bits).</li><li>Not depend on REFCLK being valid or even present until instructed otherwise — REFCLK validity is established during the PERST#-controlled sequencing window, not assumed.</li></ul><p>Thus, PERST# is not “just a reset” but serves as the gating signal for the entire endpoint bring-up state machine. The rest of this article series follows PERST# down through the core, the PHY, and the PIPE interface.</p><h3>PERST#Timing: CEM Specification Requirements</h3><p>The CEM specification defines the PERST# related timing for add-in cards. Every embedded implementation modeling itself on CEM AIC behavior must comply to these timings. The two timing parameters that matter most are:</p><ul><li><strong>Minimum PERST# assertion time relative to power rail stability</strong>: PERST# must remain asserted for a defined minimum period after the power rails (12V/3.3V) have reached and stabilized within specification, before it is permitted to deassert. This gives downstream voltage regulators, PLLs, and analog bias circuits time to settle. This is denoted as TPVPERL in the following diagram.</li><li><strong>Minimum REFCLK-stable-to-PERST#-inactive time</strong>: REFCLK must be stable and within spec for a defined minimum duration <em>before</em> PERST# is deasserted, because the endpoint’s PHY PLL will begin attempting to lock the moment reset is released, and locking against an unstable or not-yet-running reference clock produces unpredictable, non-repeatable PHY behavior. This is denoted as TPERST-CLK in the following diagram</li></ul><p><strong>Critically, there is no maximum time specified.</strong> PERST# may remain asserted indefinitely with no protocol-level consequence — a system can sit with PERST# held low for milliseconds, seconds, or (in some low-power/standby platform states) far longer, and the endpoint is required to simply continue waiting in its reset state. This “no max” property is what makes PERST# usable as a general-purpose platform sequencing tool rather than a narrowly-timed protocol signal. This lets platform designers freely gate PERST# release behind arbitrarily long board-level or firmware-level sequencing without violating the spec.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/972/1*YtC5BVCZ36L44hha1Qgrfg.jpeg" /><figcaption>PERST# and other signal timing (Reference: CEM Specification 6.0)</figcaption></figure><p>PVPERL = 100ms</p><p>TPERST-CLK = 100us</p><p>In the next part of this article series, we delve deep into the relevance of PERST# in an Endpoint — from the design stage of the SoC all the way up to board bring up.</p><p>Are you facing problems bringing up your EP? Or want to pass PCI-SIG compliance? Get in touch with us. <a href="http://www.bluehatsoft.com/contact">www.bluehatsoft.com/contact</a> Or email us contact(at-the-rate)bluehatsoft(dot)com.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=85be3f179118" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ARM64 Normal Memory Attributes]]></title>
            <link>https://medium.com/@om.nara/arm64-normal-memory-attributes-6086012fa0e3?source=rss-de8ac1f5583c------2</link>
            <guid isPermaLink="false">https://medium.com/p/6086012fa0e3</guid>
            <category><![CDATA[mmu]]></category>
            <category><![CDATA[soc]]></category>
            <category><![CDATA[embedded-systems]]></category>
            <category><![CDATA[arm]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Om Narasimhan]]></dc:creator>
            <pubDate>Tue, 14 Jan 2020 03:45:06 GMT</pubDate>
            <atom:updated>2020-01-14T03:45:06.482Z</atom:updated>
            <content:encoded><![CDATA[<p>This article describes some of the AArch64 Normal Memory Attributes. For a description of System Memory and Normal Memory, see this <a href="https://medium.com/@om.nara/arm64-system-memory-fbf71dce37ee">article</a>. For Device memory attributes, see this <a href="https://medium.com/@om.nara/aarch64-device-memory-attributes-744fd0aea02">article</a></p><p>Many properties (e.g., memory type, cacheability, shareability … et al. of memory regions are controlled by the attributes associated with that memory region. My previous article <a href="https://www.linkedin.com/pulse/aarch64-shareability-domains-normal-memory-om-narasimhan?articleId=6575187481132625921#comments-6575187481132625921&amp;trk=public_profile_article_view">here</a> explains the attributes associated with Device memory. This article complements it with similar treatment on normal memory.</p><p>Normal memory is generally divided into pages and accessed through the processor’s hardware circuitry implemented to walk the page tables. This access is controlled and regulated by the attributes associated with the page table entries.</p><h4>Table descriptors</h4><p>Format of different page table entries are described in this article. For a quick reference, it is reproduced here.</p><p>Table descriptor entries in the page table have their bits[1:0] == 0b11, and the level cannot be 3.</p><h4>Table descriptor format</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/726/1*nPyr_BcjJdbEHT8aPWmuzw.png" /><figcaption>AArch64 Page Table descriptor format (with TG size 4KB)</figcaption></figure><h4>Table descriptor attributes</h4><p>Please note that Stage2 table descriptors do not include any attribute field. The following table describes the attributes associated with a Stage 1 Table entry.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/802/1*XB9eNrtT6grf5cMjbMDdAQ.png" /><figcaption>AArch Page Table descriptor attributes</figcaption></figure><h4>NSTable</h4><p>This bit indicates whether the table identifier in the descriptor is located in Secure PA space (NSTable == 0) or Non-Secure (NSTable == 1) memory for an access from Secure state.</p><p>If NSTable == 1, any value of NS bit on the page or block descriptor on any subsequent lookup is ignored and the block or page referred to is in Non-Secure memory. Also, the value of NSTable in any further looked up table is ignored and such tables’ entries refer to Non-Secure memory. Further, an entry fetched in the secure state is treated as nG == 1 (non-global).</p><p>Note: The effect of NSTable bit applies to all subsequent lookups in the translation table walk.</p><h4>APTable</h4><p>APTable bits set permissions on, at one level of translation, the referred entries at subsequent levels of lookup in the same stage of translation.</p><p>For single exception level translation regimes (Secure EL3 and Non-Secure EL2), APTable bit 0 is RES0, making only the bit 1 valid. If set (APTable[1:0] = 0b1x), Write access is not pemitted at any exception level, irrespective of permissions on subsequent level lookup.</p><p>In TRs with multiple stage translations, APTable controls only the Stage1 translation controls. Stage 2 descriptors have the APTable bits set to RES0 (HW ignores the value).</p><p>Full description of APTable bits for multiple exception level translation regimes are:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/787/1*Exg23F1i2KX2VHeXBazmwA.png" /><figcaption>APTable fields</figcaption></figure><h4>UXNTable/XNTable</h4><p>Stands for Unprivileged eXecute Never / eXecute Never.</p><p>If multiple VA ranges are supported in Stage1, this field is called UXNTable and, determines if instructions that is fetched from the region referred to by subsequent levels of look up can be executed at EL0.</p><p>If only one VA is supported in Stage1, this field is XNTable, and exercises control over eXecute Never behavior, for the same stage of translation:</p><ul><li>If the bit is UXNTable and set to 1, then UXN bit is treated as set in all subsequent levels lookup, irrespective of the actual value set in the descriptors.</li><li>If the bit is XNTable and set to 1, then XN bit is treated as set in all subsequent levels lookup, irrespective of the actual value set in the descriptors.</li><li>If set to 0, this bit has no effect.</li></ul><h4>PXNTable</h4><p>Stands for Privileged eXecute Never.</p><p>This bit is valid only for a stage1 translation that can support two VA ranges and treated RES0 for stage1 translations that support only one VA range.</p><p>When PXNTable bit is set to 1, the PXN bit is treated as set to 1 for all subsequent levels of lookup, irrespective of the actual value set in the descriptors, and the instructions fetched from the corresponding region cannot be executed in EL1 and higher exception levels.</p><h3>Block/Page descriptors</h3><p>Format of different page table entries are described in this article. For a quick reference, it is reproduced here.</p><p>Block descriptor entries in the page table have their bits[1:0] == 0b01.</p><p>Page descriptor entries in the page table have their bits[1:0] == 0b11, and the level must be 3.</p><h4>Page descriptor format</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/726/1*DmNEHa8ZjQVRDF9BFBDPjg.png" /><figcaption>AArch64 Page descriptor format (TG size = 4KB)</figcaption></figure><h4>Block descriptor format</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/726/1*3a4Qh7v2NvK2d0kqYHP1PQ.png" /><figcaption>AArch64 Block descriptor format (TG size = 4KB)</figcaption></figure><p>The meaning of the fields of the page table entries (block descriptors, page descriptors and table descriptors) depend on the translation regime being used. For more info on translation regime and stages of memory translations, please refer to this article.</p><h4>Page/Block descriptor attributes</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/809/1*1OA7G9W5N02emdD_Wg5Shg.png" /><figcaption>AArch64 Page/Block descriptor attributes</figcaption></figure><h4>UXN</h4><ul><li>Bit 54 is defined as UXN only for stage1 tables entries of any translation regime for which Stage1 supports two VA ranges.</li><li>This field applies only EL0 code execution.</li><li>If 0, execution of code is permitted for EL0.</li></ul><h4>XN</h4><ul><li>Bit 54 is defined as XN for a translation regime for which Stage1 can support only a single VA range.</li><li>This field applies to any exception level to which the translation applies.</li><li>If 0, execution of code is permitted, otherwise execution not permitted.</li></ul><h4>PXN</h4><ul><li>Bit 53 is defined as PXN only for Stage1 tables entries of any translation regime for which Stage1 supports two VA ranges. For TRs supporting single VA range, this bit is RES0 and ignored by hardware.</li><li>This field applies only exception levels higher than EL0 code execution.</li><li>If 0, execution of code is allowed.</li></ul><h4>Contiguous</h4><p>Applicable only for the initial lookup for Stage2, hinting the hardware that it can be cached in a single TLB entry because they all share same set of attributes and permissions.</p><h4>DBM</h4><p>This bit indicates that the contents of a page or section of memory is modified (Dirty state). This bit can be optionally controlled by the hardware, if the hardware management of the access flag is enabled. The field HD of TCR_ELx register (TCR_ELx.HD) can be set to enable the hardware management of this bit.</p><p>This is an optional feature supported by the hardware implementation. If this feature is not supported, TCR_Elx.HD is RES0 (hardware ignores the value)..</p><h4>nG</h4><p>Bit 11 is defined as nG only for Stage1 tables entries of any translation regime for which Stage1 supports two VA ranges. For TRs supporting single VA range, this bit is RES0 and ignored by hardware.</p><h4>AF</h4><ul><li>This bit is managed by software in ARMv8.0 and can optionally be managed by hardware if extension ARMv8.1-TTHM is implemented.</li><li>Indicates when a page or block is accessed for the first time since the AF was set to 0.</li><li>Every time a descriptor entry with AF == 0 is attempted to be read into TLB, an access fault is generated. The SW should set AF=1 for that descriptor.</li></ul><h4>SH[1:0]</h4><ul><li>Applicable only to normal, cacheable memory (decided by AttrInx[2:0]).</li><li>Stage1 and Stage2 has the following meanings (0b01 is reserved):</li><li>0b00 — Non-shareable.</li><li>0b10 — Outer Shareable.</li><li>0b11 — Inner Shareable.</li></ul><h4>AP[2:1] — Data access permissions</h4><ul><li>For stage1 translations (TRs spanning more than one ELs):</li><li>0b00: No access from EL0, Read/Write access from all higher levels.</li><li>0b01: Read/Write from EL0, Read/Write access from all higher levels.</li><li>0b10: No access from EL0, Read only access from all higher levels.</li><li>0b11: Read only access from EL0, Read only access from all higher levels.</li><li>For Stage1 translations (TRs with single Els), AP[1] is RES1:</li><li>0b0: Read/Write.</li><li>0b1: Read only.</li><li>For stage2 translations, S2AP field affects the access permissions and will be combined with AP[2:1].</li></ul><h4>NS — Non-Secure access control</h4><ul><li>0b1: Access granted for Secure and Non-Secure execution state.</li><li>0b0: Access granted only for Secure execution state.</li></ul><h4>MemAttr[3:0] — memory attribute index in the MAIR_ELx register</h4><ul><li>Can differentiate between device memory and Normal memory.</li><li>For normal memory, contains cacheability (Writeback/Writethrough), shareability (Inner/outer), allocate (Read/Write) policy hints … et al.</li></ul><h3>Preventing execution from Writable memory</h3><p>As an extended security measure, AArch64 supports preventing execution from writable memory on all Exception Levels and translation regimes in the register field SCTLR_ELx.WXN</p><ul><li>For a TR that applies to EL0 and a higher EL, when the corresponding SCTLR_Elx.WXN == 1:</li><li>All regions that are writable from EL0 at stage1 of the address translation are treated XN == 1.</li><li>All regions that are writable from EL1 at stage1 of the address translation are treated PXN == 1.</li><li>For a TR that applies to only one Exception Level, when the corresponding SCTLR_Elx.WXN == 1, all regions that are writable from Stage1 of the address translation are treated UXN == 1.</li></ul><p>— End of article</p><p>Please leave your comments, opinions … et al in the comments section.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6086012fa0e3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ARM64 System Memory]]></title>
            <link>https://medium.com/@om.nara/arm64-system-memory-fbf71dce37ee?source=rss-de8ac1f5583c------2</link>
            <guid isPermaLink="false">https://medium.com/p/fbf71dce37ee</guid>
            <category><![CDATA[aarch64]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[mmu]]></category>
            <category><![CDATA[arm]]></category>
            <category><![CDATA[soc]]></category>
            <dc:creator><![CDATA[Om Narasimhan]]></dc:creator>
            <pubDate>Thu, 19 Dec 2019 01:22:01 GMT</pubDate>
            <atom:updated>2019-12-19T01:22:01.518Z</atom:updated>
            <content:encoded><![CDATA[<h4>ARM AArch64: Shareability domains and Normal memory</h4><p>This article explains the concepts of Shareability for normal memory and touches upon its impact on overall Coherency and Cacheability on an AArch64 System design. Parts of these points hold good for non-AArch64 System design as well.</p><p>In most systems, normal memory constitutes a major portion of the addressable memory. The most important factor to claim a specific memory as normal memory is its being idempotent. That is, the memory should exhibit all of the following properties:</p><ul><li>No side effects for read operation and repeated read operations.</li><li>No side effect for write operation and repeated write operations to the same address location.</li><li>Multiple accesses can be merged without side effects for the same type (Read/Write) of access.</li><li>Read operation returns the last written value irrespective of the number of times read operation is performed.</li><li>Read operation can fetch additional memory contents without side effects.</li><li>Unaligned access can be supported.</li></ul><p>In addition to being idempotent, an implementation of Normal memory exhibits the property of the write operation being completed in finite amount of time.</p><ul><li>This means that, within that memory’s shareability domain, an observer should see the write completed in finite amount of time without the need of using explicit cache maintenance instructions or memory barriers.</li><li>If the normal memory is accessed as non-cacheable memory, then the completed write should be observed globally by all observers in finite amount of time without the need of using any cache maintenance instructions.</li></ul><h4>Shareability domains for Normal memory</h4><p>Shareability attribute of a memory location is something the hardware enforces for specific coherency requirement of that memory location</p><p>A normal memory location can have a shareability attribute like:</p><ul><li>Inner shareable</li><li>Outer shareable</li><li>Non shareable</li></ul><p>Please note that these attributes define <strong>only the data coherency requirements</strong>. These <strong>do not define Instruction fetch coherency requirements</strong></p><p>Inner shareable domain is defined, for a normal memory location with Inner Shareable attribute set, as</p><ul><li>One or more of observers that are coherent in data access to this location.</li><li>Each of these observers are independently coherent in data access to this location.</li></ul><p>Outer shareable domain is defined, for a normal memory location with Outer Shareable attribute set, as</p><ul><li>One or more of observers that are coherent in data access to this location.</li><li>Each of these observers are independently coherent in data access to this location.</li></ul><p>In addition to these definitions, some additional properties of the shareability domains are:</p><ul><li>Each observer is only a member of a single Inner Shareability domain.</li><li>Each observer is only a member of a single Outer Shareability domain.</li><li>All observers that are members of an Inner shareability domain are always the members of the same Outer Shareability domain.</li></ul><p>Also</p><ul><li>If a location is Non-Cacheable, add data access to it <strong>is coherent to all observers</strong>. Hence Non-Cacheable locations are <strong>always considered Outer shareable</strong> to all observers.</li></ul><p>In a system design, if multiple PEs are controlled by the same instance of a hypervisor or operating system, all those PEs are to be the member of a single Inner Shareable domain.</p><h4>Example1: A system design with Asymmetric Multi Processing</h4><p>Asymmetric Multi Processing is where the different PEs run different Operating systems or Hypervisors.</p><p>For illustration, let us assume a fictitious AArch64 implementation with the following components</p><ul><li>Multi socket/CPU system with 4 PEs per socket.</li><li>Each PE has a small amount of addressable on-chip-memory that is banked per PE, giving each PE access its local OCM using the same address range.</li><li>Each A53 PE has independent L1 cache.</li><li>Each Socket has L2 cache shared among A53s.</li><li>An FPGA implementation of a kind of RAM is connected to the system. All PEs have access to this FPGARAM.</li></ul><p>This system is designed for AMP where PE (0–3) <strong>always</strong> run an instance of a hypervisor/OS and PE4–7 <strong>always</strong> run another instance of a hypervisor/OS, the shareability domains could be</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/577/1*NfNKAQ_UGdg_vrFAuw_eRw.png" /><figcaption>Memoty Attributes of an AMP system</figcaption></figure><p>In the illustration,</p><ul><li>Each PE’s OCM is not shareable (OCM is aliased and accessed as the same address range in all PEs), but cacheable.</li><li>Socket-0 and connected DDR0 are in a single inner shareable domain. Socket 0 runs a Hypervisor.</li><li>Socket-1 and connected DDR1 are in a single inner shareable domain. Socket 1 runs a bare-metal Linux instance.</li><li>The FPGARAM connected through the PCIe RC, with both Sockets are in the same outer shareable domain.</li></ul><p>Illustration of the AMP system Characteristics of the AMP system</p><p>What this configuration means is</p><p>For L1 and L2 caches,</p><ul><li>L1 and L2 caches fall into the same inner shareable domain. Both are kept coherent by hardware for all cached accesses except to those to OCM.</li></ul><p>For OCM,</p><ul><li>OCM addresses but must be marked Non-Shareable as they are not shared across PEs (even those of same socket). This is alright because OCM is banked per PE. There is no hardware enforced coherency for accesses to OCM because OCM cannot be accessed outside the PE anyway. They can be marked cached or non-cached.</li></ul><p>For DDR0 and DDR1</p><ul><li>If DDR is cached and marked Inner shareable, hardware enforces coherency to the local DDR accesses. No special cache instructions are required for PEs of same socket to access the local DDR contents.</li><li>If DDR is cached and marked Outer shareable, hardware enforces coherency to the local and non-local DDR accesses. No special cache instructions are required for a PEs to access the DDR contents irrespective of the DDR locality.</li><li>If DDR is cached and marked both Inner and Outer shareable, hardware enforces coherency to the local and non-local DDR accesses. No special cache instructions are required for a PEs to access the DDR contents irrespective of the DDR locality.</li><li>DDR memory cannot be marked non-shareable (if done so, unexpected behavior may result).</li><li>If DDR is uncached, it is treated outer shareable.</li></ul><p>For FPGA RAM</p><ul><li>If FPGARAM is cached and marked Outer shareable, hardware enforces coherency to the FPGARAM accesses. No special cache instructions are required for a PEs to access the FPGARAM contents.</li><li>FPGARAM should not be marked Inner shareable as it does not belong to an Inner shareable domain.</li><li>If FPGARAM is uncached, it is treated as Outer Shareable.</li></ul><h4>Example2: A system design with Symmetric Multi Processing</h4><p>In Symmetric multi processing, one instance of the operating system or hypervisor runs on all the PEs. Such a situation mandates all PEs and the memory accessed by them fall into the same Inner shareable domain.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/642/1*nHBUENJWsTh5XsZWTgw1OA.png" /><figcaption>Memoty Attributes of an SMP system</figcaption></figure><p>Illustration of the SMP System Characteristics of the SMP System</p><p>Here, the only difference from AMP design with two inner shareable domain is that, if the DDR are cached, for any PE, no cache management instructions are required to coherently access non-local DDR contents as local as well as non-local RAM falls into the same Inner shareable domain.</p><p>Note: This is just one possible design. For example, there is nothing that prevents the system architect from extending the Inner Shareable domain to include the FPGA Memory.</p><p>— End of article</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fbf71dce37ee" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AArch64 Device Memory Attributes]]></title>
            <link>https://medium.com/@om.nara/aarch64-device-memory-attributes-744fd0aea02?source=rss-de8ac1f5583c------2</link>
            <guid isPermaLink="false">https://medium.com/p/744fd0aea02</guid>
            <category><![CDATA[embedded-systems]]></category>
            <category><![CDATA[soc]]></category>
            <category><![CDATA[mmu]]></category>
            <category><![CDATA[arm]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Om Narasimhan]]></dc:creator>
            <pubDate>Tue, 29 Oct 2019 02:29:31 GMT</pubDate>
            <atom:updated>2019-10-29T02:29:31.492Z</atom:updated>
            <content:encoded><![CDATA[<p>AArch64 System programmers who deal with Devices and Device memory often encounter device specific memory’s attributes like Gather, Reorder and Early write acknowledgement, collectively quoted as GRE/nGnRnE and/or various combinations of these (nGRnE, GnRE … etc.). This article attempts to elucidate on these attributes and their relevance to Device memory, and to give some examples where these attributes can be useful. In addition, the constraints associated with using the device memory for instruction fetches are also covered.</p><h3>Gather(G)/non-Gather(nG)</h3><p>If, for a block of device memory, Gather attribute is set, it means that</p><ul><li>Multiple memory accesses of the same type (multiple reads or multiple writes) to the same memory location can be combined to a single transaction.</li><li>Multiple memory accesses of the same type to different memory locations within the block can be combined to a single memory transaction on an interconnect.</li></ul><p>Either of these behaviors is permitted only if the ordering and coherency rules of the memory location can be followed. In case of conflicts, ordering and coherency rules take precedence.</p><p>The most observable manifestation of these behaviors is the number of memory accesses at the endpoint location (memory) being less than the number of accesses generated by the running executive. By corollary, for memory regions with Gather bit clear, the number of memory accesses at the endpoint location is exactly same as the number of memory accesses generated by the running executive.</p><h4>Some important points</h4><ul><li>Gathering across memory barriers (DMB/DSB and variants) is not permitted. (Well, there are some qualifications to the permission, but that is set aside for a later discussion).</li><li>Gathering across memory fences (load-acquire, store-release) are not permitted.</li><li>If the target memory is non-Gather, a read from that memory cannot come from the cache, or a buffer that is not a part of the target endpoint for that address in the memory system.</li><li>In other words, the read MUST reach the target endpoint and result must return results from the target endpoint.</li><li>ARM architecture defines the PE observable behavior for Gather attribute. The implementations are free to perform gather in a non-observable manner by the PE.</li><li>That is, the semantics of Gather attribute does not define how the target endpoint implements the memory access.</li></ul><p>Device memory that maps to various registers internal to device and is exposed through MMIO interface is generally attributed as non-Gather. Some examples of such registers are:</p><ul><li>Control registers: Different bits may control different device aspects or behaviors. Combining writes to such registers would sometime cause unexpected behaviors.</li><li>Read only registers with side effects: Many a times, status registers are implemented as Clear on read (CoR) registers. Such register read accesses must be individually honored and must not be combined.</li></ul><h3>Reorder(R)/non-Reorder(nR)</h3><p>For all device memory with non-Reordering attribute, the order of memory accesses arriving at that memory of size SIZE (as defined by the device) must be the same order that is generated by the executive in the PE — the accesses must appear in the program order</p><p>Note: The SIZE is generally defined as the same as the memory size operated on by a DMB instruction</p><p>An example of memory where non-Reorder attribute is recommended is a PCIe device’s internal register space which is externally mapped to host MMIO via one or more PCIe BARs</p><p>An example of memory where Reorder attribute MAY BE recommended is a PCIe device’s internal RAM memory which is externally mapped to host MMIO via one or more PCIe BARs. Please note that, in such a case, the implementor need to ensure that reordered transactions won’t cause unexpected behavior.</p><p>In an implementation, it is permitted to perform an access with the Reordering attribute set in a manner consistent with the requirement consistent with non-Reordering attribute. But the corollary is not true.</p><p>For a non-Reorder supported implementation, there are no additional ordering requirements to meet for accesses between</p><ul><li>Areas with non-Reordering attribute and Reordering attribute.</li><li>Areas with non-Reordering attribute and normal memory.</li><li>Areas with non-Reordering attribute and other peripherals (access size defined by the other peripheral).</li></ul><h3>Early Write Acknowledgement (E/nE)</h3><p>For memories in the endpoints for which the PE requires that the acknowledgement of a write comes from the endpoint, non-Early Write Acknowledgement attribute guarantees that</p><ul><li>Only the endpoint of the write operation can return a Write Acknowledgement.</li><li>No intermediate agents can return a Write Acknowledgement.</li></ul><p>This means that a DMB instruction completes only after the write to the endpoint memory reaches and acknowledged by the endpoint</p><h4>Note</h4><ul><li>This attribute defines the endpoint from which the acknowledgement should come out. This attribute does not control the order in which such acknowledgements should come out.</li><li>PCI/PCIe configuration space is a good example for nE attribute. Memory areas within PCIe devices that expects the posted memory writes are good examples of E attribute.</li></ul><h3>Device memory and instruction fetches</h3><p>Software should not make the CPU fetch instructions from Device memory. Such fetches may result in undefined behavior. Yet, there are some circumstances under which such fetches may be allowed</p><ul><li>If specific areas in device memory are not marked as execute-never for the current exception level, and if the address translation is enabled, then those areas can be used for speculative instruction accesses.</li><li>If specific areas in device memory are not marked as execute-never for the current exception level, and if a branch instruction causes the PC to point to such an area of memory, then the implementation can</li><li>Generate a permission fault.</li><li>Treat the pointed area as Normal, Non-cacheable memory.</li></ul><p>Please feel free to leave your comments and questions.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=744fd0aea02" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AArch64 Exception Levels]]></title>
            <link>https://medium.com/@om.nara/aarch64-exception-levels-60d3a74280e6?source=rss-de8ac1f5583c------2</link>
            <guid isPermaLink="false">https://medium.com/p/60d3a74280e6</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[soc]]></category>
            <category><![CDATA[mmu]]></category>
            <category><![CDATA[arm64]]></category>
            <category><![CDATA[embedded-systems]]></category>
            <dc:creator><![CDATA[Om Narasimhan]]></dc:creator>
            <pubDate>Wed, 23 Oct 2019 01:11:16 GMT</pubDate>
            <atom:updated>2019-10-23T01:11:16.111Z</atom:updated>
            <content:encoded><![CDATA[<p>ARMv8 architecture associates Exception levels with software execution privileges and defines a set of four Exception Levels (EL0, EL1, EL2 and EL3) where:</p><p>With reference to privilege of execution, EL0 &lt; EL1 &lt; EL2 &lt; EL3. That is,</p><ol><li>EL0 is the lowest privileged execution level.</li><li>EL3 is the highest privileged execution level.</li></ol><ul><li>EL0 is also called the unprivileged level of execution. This is the level at which normal applications run (in userspace).</li><li>EL3 is the only privilege level in which security state associated with the execution can be changed. That is, switching from Non-Secure execution state to Secure execution state OR Secure execution state to Non-Secure execution state can be done only when the software executes at privilege level EL3.</li><li>Usually, the software running at EL3 is known as Secure Monitor.</li><li>EL2 provides only Non-Secure state of execution and is used for running Hypervisor (for Virtualization).</li><li>Operating system kernels usually run at EL1 exception level.</li><li>Not all exception levels are required to be implemented in a specific hardware implementation of AArch64.</li><li>It is not mandatory to implement contiguous exception levels. i.e.,</li></ul><ol><li>An implementation can opt to implement only EL3, EL1 and EL0, dropping support for virtualization altogether.</li></ol><ul><li>Support for EL3 and EL2 are<strong> optional </strong>for a hardware implementation.</li><li>Support for EL0 and EL1 are<strong> mandatory </strong>for a hardware implementation.</li></ul><h3>Switching execution between exception levels</h3><p>Processor can switch exception levels only while either taking an exception or returning from an exception</p><ul><li>While taking an exception, the exception level can either switch to a higher privilege level or stay at the same level.</li><li>While returning from an exception, the exception level can either switch to a lower privilege level or stay at the same level.</li></ul><h3>Exception Generation</h3><p>An exception is termed “generated” when the processing element (PE) responds to condition that caused the exception. The PE state at this time is known as the state the exception is taken from. The PE state immediately after taking the exception is known as the state the exception is taken to.</p><h3>Exception return</h3><p>To return from an exception, the processing element executes the instruction ERET (Exception return). The processing element state when exception return instruction is executed (well, committed to be executed, rather) is the state when the exception is returned from. The processing element state immediately after the execution of that instruction is the state exception returns to.</p><h3>32 bit Exception Levels</h3><p>Exception levels can execute in 64 bit mode (called “Using AArch64”) or 32 bit mode (called “Using AArch32”).</p><p>AArch64 supports <strong>all exception levels</strong> using AArch64, and <strong>some exception levels</strong> using AArch32.</p><h4>Notes:</h4><ul><li>EL3 is implemented only using AArch64.</li><li>For an Exception level <strong>to use AArch64, the immediate higher exception level <em>must</em> use AArch64</strong>. That is:</li><li>EL0 can use AArch64 <strong>only when</strong> EL1 uses AArch64.</li><li>EL1 can use AArch64 <strong>only when</strong> EL2 uses AArch64.</li></ul><h3>Moving between AArch32 and AArch64</h3><p>Moving execution between AArch32 and AArch64 execution states is called “interprocessing”</p><ul><li>Execution state can change <strong>only when</strong> the Exception level is changed. That is, either on taking an exception, or on returning from an exception.</li></ul><p>On taking an exception, if the Exception level changes, the Execution state can</p><ul><li>Remain unchanged, OR</li><li>Change from AArch32 to AArch64.</li></ul><p>On returning from an exception, if the Exception level changes, the Execution state can</p><ul><li>Remain unchanged, OR</li><li>Change from AArch64 to AArch32.</li></ul><h3>Exception Levels and Software stacks</h3><p>Different layers of the software (applications, OS kernels, Hypervisor … et. al.) can be executing at different exception levels. They could be using different modes (AArch64 or AArch32) as well.</p><p>The processing element can change execution state only either:</p><ul><li>At reset.</li><li>On change of exception level.</li></ul><p>The following diagram shows different security states and exception levels normally associated with different layers of software stacks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1010/1*xPvKe9R5SXe8RwEOklXX0Q.png" /><figcaption>ARM64 Exception levels and typical use cases</figcaption></figure><h3>Hardware with a subset of Exception levels implemented</h3><p>As previously stated, <strong>EL0 and EL1 are mandatory</strong> in all hardware implementations and <strong>EL2 and EL3 are optional</strong>.</p><h4>When EL2 is not implemented and EL3 is implemented</h4><ul><li>HW assisted virtualization is <strong>not</strong> supported.</li><li>Security mode change (Secure to non-Secure mode and vice versa) <strong>is</strong> supported.</li></ul><h4>When EL3 is not implemented and EL2 is implemented</h4><ul><li>HW assisted virtualization <strong>is</strong> supported.</li><li><strong>Only Non-secure</strong> mod of execution is supported.</li><li>Security mode change (Secure to non-Secure mode and vice versa) is <strong>NOT </strong>supported.</li></ul><h4>When EL2 and EL3 are not implemented</h4><ul><li>Either secure mode <strong>or</strong> non-Secure mode is supported during run time.</li><li>Security mode change (Secure to non-Secure mode and vice versa) is NOT supported during run time.</li><li>At reset, processing element can either start execution on Secure mode or in non-Secure mode (The selection is usually made by a implementation defined method — like configuration pin on the board).</li></ul><p>Please leave your comments and other feedback here</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=60d3a74280e6" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>