From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-oi1-f195.google.com (mail-oi1-f195.google.com [209.85.167.195]) by mx.groups.io with SMTP id smtpd.web11.13063.1583588062760104360 for ; Sat, 07 Mar 2020 05:34:23 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@linaro.org header.s=google header.b=s2yHLsIZ; spf=pass (domain: linaro.org, ip: 209.85.167.195, mailfrom: ard.biesheuvel@linaro.org) Received: by mail-oi1-f195.google.com with SMTP id c1so5561829oiy.2 for ; Sat, 07 Mar 2020 05:34:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=Fk7ArtIiZLqkE1jGnU3eKY2mwGltERCPOujSkL27bbA=; b=s2yHLsIZjRx/yLccm1kPS3QakzcT7N6QjwZOBbbIDMZ30eDzCUzgH9Iw5qo6EaEjkJ Mge0R+U73KHWBGOnD+u0LnoB8fp7P+W3iNK2xumwkBEsatEKahglr+KxEM1QdFKqbzwG yC6FDeI5DV6ekEvrIjm4f0GL8xtxIs0e1DpUF0g680ye1Oim7s1Dg3ZLIdPQLdEoRLYU q38CQX7vAIEcgmaFIK3EUv3YBTTiUdza6FTRWSjzqmUSMW/UKfSGZY48jFYisv8IWFYG 73asxOlo4P9lNKYa/4rNbB8Cs2sLwM4+0fCiqx2l/PEWiPX6stGYjPqC3KWeUHE1ggzI IObg== 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; bh=Fk7ArtIiZLqkE1jGnU3eKY2mwGltERCPOujSkL27bbA=; b=dys+UFx2DIVjGcPsEHQ27g6REgKZuAl7LHxI/Rh+6nuTPPp4PAs1ot936u6plQ3kXx VeRMX2aRoOtv8J6V9Dc0xXTJBAITEgkidLYrN7RQBypiBThG6JFWdGjE5grD66PeKXhx 4f3dKHF+zby8ryLfEL7iYOfdAQ6frmvoOQazCfxhMbqfI5FUtM1zepqDQnDXoxIdELqQ YDiy//V+S3iBXL6DfXn2NFKfCU6y+5ov3Hdl+cRYgpNghVsYrWHx69pN1QjM+JipEBq4 Vfjp+NO3eqsiyguVaA4xudeN0nIP7ON9hDz9E6zh5d2QcwQJrhRJf4lG8rrXdzZwJU+t ManQ== X-Gm-Message-State: ANhLgQ3kg+DU/64ESumNKSeEp7IsiBW0OqZshn9HRaB5y6C0M7+KFp8b qB5Q8IOFuWjvmAP9Y4AIqsZApXYRL3RLgg== X-Google-Smtp-Source: ADFU+vsVwhzXvaed6788eD3uoENuUwFV5x8rBuHn1tSTr7GMsQ/g9D4ZjOADJlxelrZPDMv3gKLcMw== X-Received: by 2002:a05:6808:1cf:: with SMTP id x15mr6069447oic.44.1583588061618; Sat, 07 Mar 2020 05:34:21 -0800 (PST) Return-Path: Received: from cam-smtp0.cambridge.arm.com ([2a01:cb1d:112:6f00:816e:ff0d:fb69:f613]) by smtp.gmail.com with ESMTPSA id l15sm7775815otf.12.2020.03.07.05.34.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 Mar 2020 05:34:20 -0800 (PST) From: "Ard Biesheuvel" To: devel@edk2.groups.io Cc: leif@nuviainc.com, Ard Biesheuvel Subject: [PATCH 0/2] ArmPkg/ArmMmuLib AARCH64: correctness fix Date: Sat, 7 Mar 2020 14:34:13 +0100 Message-Id: <20200307133415.18857-1-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.1 Last one, I promise :-) The new ArmMmuLib code is easier to reason about, so that is what I did: currently, when we create mappings that cover existing table entries, we may end up overwriting those with block entries without taking the mapping attributes of the original table entries into account. So let's fix this. I honestly don't know whether the original code was better at dealing with this: I do remember some changes from Heyi that may have been related, but the old code is not easy to follow. In any case, I didn't manage to hit this case in practice, given that we typically start out with large mappings, and break them down later (to set permissions), rather than the other way around. Patch #1 adds some helpers to hide the insane way the type bits change meaning when you change to level 3. Patch #2 ensures that we only replace (and free) table entries with block entries if it is guaranteed that doing so will not lose any attribute information. Ard Biesheuvel (2): ArmPkg/ArmMmuLib AARCH64: use helpers to determine table entry types ArmPkg/ArmMmuLib AARCH64: preserve attributes when replacing a table entry .../Library/ArmMmuLib/AArch64/ArmMmuLibCore.c | 61 ++++++++++++++++--- 1 file changed, 54 insertions(+), 7 deletions(-) -- 2.17.1