From: Andrew Jones <andrew.jones@linux.dev>
To: "Clément Léger" <cleger@rivosinc.com>
Cc: kvm-riscv@lists.infradead.org, atishp@rivosinc.com,
jamestiotio@gmail.com
Subject: Re: [kvm-unit-tests PATCH 11/10] riscv: sbi: Add fwft pte_hw_ad_updating test
Date: Thu, 27 Feb 2025 13:07:18 +0100 [thread overview]
Message-ID: <20250227-aa83c6934b574c860989b31b@orel> (raw)
In-Reply-To: <8f02937b-4a01-4c69-91a2-59623ef81246@rivosinc.com>
On Thu, Feb 27, 2025 at 10:09:42AM +0100, Clément Léger wrote:
...
> > + report(hw_updating_enabled != *triggered &&
> > + adue_check_pte(pte_val(*ptep), write), "%s %s",
> > + hw_updating_enabled ? "hw updating enabled" : "hw updating disabled", op);
>
> Hi Andrew,
>
> adue_check_pte(pte_val(*ptep), write), "hw updating %s %s",
> hw_updating_enabled ? "enabled" : "disabled", op);
Will do
>
> > +
> > + free(ptr);
> > +}
> > +
> > +static void adue_check(bool hw_updating_enabled)
> > +{
> > + __adue_check(hw_updating_enabled, false);
> > + __adue_check(hw_updating_enabled, true);
> > +}
> > +
> > +static void fwft_check_pte_ad_hw_updating(void)
> > +{
> > + struct sbiret ret;
> > + bool enabled;
> > +
> > + report_prefix_push("pte_ad_hw_updating");
> > +
> > + ret = fwft_get(SBI_FWFT_PTE_AD_HW_UPDATING);
> > + if (ret.error == SBI_ERR_NOT_SUPPORTED) {
> > + report_skip("not supported by platform");
> > + return;
> > + } else if (!sbiret_report_error(&ret, SBI_SUCCESS, "get")) {
> > + /* Not much we can do without a working get... */
> > + return;
> > + }
> > +
> > + enabled = !!ret.value;
>
> Is there a reason to normalize value to a boolean ? The spec states that
> the values for ADUE is either exactly 0 or 1. So i'd expect value to
> contain 0 or 1 and thus no need to normalize it. That would even hide
> some invalid returned value from the SBI.
Good thought. We should test the exact 0/1.
>
> > + report(!enabled, "resets to 0");
> > +
> > + install_exception_handler(EXC_LOAD_PAGE_FAULT, adue_read_handler);
> > + install_exception_handler(EXC_STORE_PAGE_FAULT, adue_write_handler);
> > +
> > + adue_check(enabled);
> > +
> > + ret = fwft_set(SBI_FWFT_PTE_AD_HW_UPDATING, !enabled, 0);
> > + if (!sbiret_report_error(&ret, SBI_SUCCESS, "set to %d", !enabled))
> > + goto inval_tests;
> > + else
> > + enabled = !enabled;
> > +
> > + ret = fwft_get(SBI_FWFT_PTE_AD_HW_UPDATING);
> > + sbiret_report(&ret, SBI_SUCCESS, enabled, "get %d", enabled);
> > +
> > + adue_check(enabled);
> > +
> > + ret = fwft_set(SBI_FWFT_PTE_AD_HW_UPDATING, !enabled, 0);
> > + if (!sbiret_report_error(&ret, SBI_SUCCESS, "set to %d again", !enabled))
> > + goto inval_tests;
> > + else
> > + enabled = !enabled;
> > +
> > + ret = fwft_get(SBI_FWFT_PTE_AD_HW_UPDATING);
> > + sbiret_report(&ret, SBI_SUCCESS, enabled, "get %d again", enabled);
> > +
> > + adue_check(enabled);
>
> That seems like this whole block was copy/pasted, it might be factorized.
>
> > +
> > +#if __riscv_xlen > 32
> > + ret = fwft_set_raw(BIT(32) | SBI_FWFT_PTE_AD_HW_UPDATING, !enabled, 0);
> > + if (!sbiret_report_error(&ret, SBI_SUCCESS, "set to %d with high feature bits set", !enabled))
> > + goto inval_tests;
> > + else
> > + enabled = !enabled;
> > +
> > + ret = fwft_get(SBI_FWFT_PTE_AD_HW_UPDATING);
> > + sbiret_report(&ret, SBI_SUCCESS, enabled, "get %d after set with high feature bits set", enabled);
> > +
> > + adue_check(enabled);
> > +#endif
> > +
> > + ret = fwft_set(SBI_FWFT_PTE_AD_HW_UPDATING, !enabled, 1);
> > + if (!sbiret_report_error(&ret, SBI_SUCCESS, "set to %d with lock", !enabled))
> > + goto inval_tests;
> > + else
> > + enabled = !enabled;
> > +
> > + ret = fwft_get(SBI_FWFT_PTE_AD_HW_UPDATING);
> > + sbiret_report(&ret, SBI_SUCCESS, enabled, "get %d after set with lock", enabled);
> > +
> > + adue_check(enabled);
> > +
> > + ret = fwft_set(SBI_FWFT_PTE_AD_HW_UPDATING, !enabled, 0);
> > + sbiret_report_error(&ret, SBI_ERR_DENIED_LOCKED, "set locked to %d without lock", !enabled);
> > +
> > + ret = fwft_set(SBI_FWFT_PTE_AD_HW_UPDATING, !enabled, 1);
> > + sbiret_report_error(&ret, SBI_ERR_DENIED_LOCKED, "set locked to %d with lock", !enabled);
> > +
> > + ret = fwft_set(SBI_FWFT_PTE_AD_HW_UPDATING, enabled, 0);
> > + sbiret_report_error(&ret, SBI_ERR_DENIED_LOCKED, "set locked to %d without lock", enabled);
> > +
> > + ret = fwft_get(SBI_FWFT_PTE_AD_HW_UPDATING);
> > + sbiret_report(&ret, SBI_SUCCESS, enabled, "get locked %d after same set without lock", enabled);
> > +
> > + ret = fwft_set(SBI_FWFT_PTE_AD_HW_UPDATING, enabled, 1);
> > + sbiret_report_error(&ret, SBI_ERR_DENIED_LOCKED, "set locked to %d with lock", enabled);
> > +
> > + ret = fwft_get(SBI_FWFT_PTE_AD_HW_UPDATING);
> > + sbiret_report(&ret, SBI_SUCCESS, enabled, "get locked %d after same set with lock", enabled);
>
> Should this be factorized with the misaligned LOCKED testing as well ?
>
> > +
> > +inval_tests:
> > + ret = fwft_set(SBI_FWFT_PTE_AD_HW_UPDATING, 2, 0);
> > + sbiret_report_error(&ret, SBI_ERR_INVALID_PARAM, "set to 2");
> > +
> > + ret = fwft_set(SBI_FWFT_PTE_AD_HW_UPDATING, !enabled, 2);
> > + sbiret_report_error(&ret, SBI_ERR_INVALID_PARAM, "set to %d with flags=2", !enabled);
>
> Ditto.
>
> Otherwise, looks good to me.
Thanks for the review. I'll refactor as suggested. I've also got a couple
other changes to make, such as marking the reset value test as kfail,
since opensbi currently enables svadu when it's present.
I'll send a v2 of this series with patch 1/10 dropped and this patch
added after fixing it up.
Thanks,
drew
--
kvm-riscv mailing list
kvm-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kvm-riscv
prev parent reply other threads:[~2025-02-27 12:38 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-21 15:55 [kvm-unit-tests PATCH 00/10] riscv: sbi: Test improvements and a couple new Andrew Jones
2025-02-21 15:55 ` [kvm-unit-tests PATCH 01/10] riscv: sbi: Mark known fwft failures as kfails Andrew Jones
2025-02-24 16:53 ` Clément Léger
2025-02-25 10:14 ` Clément Léger
2025-02-25 10:25 ` Andrew Jones
2025-02-25 15:32 ` Andrew Jones
2025-02-25 15:48 ` Clément Léger
2025-02-26 18:01 ` Andrew Jones
2025-02-21 15:55 ` [kvm-unit-tests PATCH 02/10] riscv: sbi: Ensure we have IPIs enabled for HSM suspend tests Andrew Jones
2025-02-21 15:55 ` [kvm-unit-tests PATCH 03/10] riscv: sbi: Ensure SUSP test gets an interrupt Andrew Jones
2025-02-21 15:55 ` [kvm-unit-tests PATCH 04/10] riscv: sbi: Improve susp expected error output Andrew Jones
2025-02-21 15:55 ` [kvm-unit-tests PATCH 05/10] riscv: sbi: Improve interrupt handling cleanup Andrew Jones
2025-02-21 15:55 ` [kvm-unit-tests PATCH 06/10] lib/cpumask: Add some operators Andrew Jones
2025-02-21 15:55 ` [kvm-unit-tests PATCH 07/10] riscv: sbi: HSM suspend may not be supported Andrew Jones
2025-02-21 15:55 ` [kvm-unit-tests PATCH 08/10] riscv: sbi: Probe/skip SUSP Andrew Jones
2025-02-25 15:16 ` Clément Léger
2025-02-21 15:55 ` [kvm-unit-tests PATCH 09/10] riscv: sbi: susp: Check upper bits of sleep_type are ignored Andrew Jones
2025-02-25 15:20 ` Clément Léger
2025-02-21 15:55 ` [kvm-unit-tests PATCH 10/10] riscv: sbi: Add bad fid tests Andrew Jones
2025-02-26 17:59 ` [kvm-unit-tests PATCH 11/10] riscv: sbi: Add fwft pte_hw_ad_updating test Andrew Jones
2025-02-27 9:09 ` Clément Léger
2025-02-27 12:07 ` Andrew Jones [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250227-aa83c6934b574c860989b31b@orel \
--to=andrew.jones@linux.dev \
--cc=atishp@rivosinc.com \
--cc=cleger@rivosinc.com \
--cc=jamestiotio@gmail.com \
--cc=kvm-riscv@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).