Updated how epochs are counted.

PiperOrigin-RevId: 709111444
Change-Id: If90e2275b935f0d44c0ef81a3344d83b7ab81ac2
diff --git a/cheriot/cheriot_ibex_hw_revoker.cc b/cheriot/cheriot_ibex_hw_revoker.cc
index 4df1238..46b4b2a 100644
--- a/cheriot/cheriot_ibex_hw_revoker.cc
+++ b/cheriot/cheriot_ibex_hw_revoker.cc
@@ -251,14 +251,14 @@
 
 void CheriotIbexHWRevoker::Revoke() {
   if (!sweep_in_progress_) return;
-  // Increment the epoch.
-  epoch_++;
   uint64_t cap_address = start_address_ + (current_cap_++ << 3);
   // Align address to the capability size.
   cap_address &= ~0b111ULL;
   ProcessCapability(cap_address);
   // Check to see if we have reached the end of the region.
   if (cap_address >= end_address_) {
+    // Increment the epoch.
+    epoch_++;
     sweep_in_progress_ = false;
     SetInterrupt(true);
   }
diff --git a/cheriot/test/cheriot_ibex_hw_revoker_test.cc b/cheriot/test/cheriot_ibex_hw_revoker_test.cc
index cb5c7f6..8f89c5d 100644
--- a/cheriot/test/cheriot_ibex_hw_revoker_test.cc
+++ b/cheriot/test/cheriot_ibex_hw_revoker_test.cc
@@ -286,13 +286,13 @@
   for (int i = 0; i < num; ++i) {
     AdvanceRevoker();
     EXPECT_EQ(GetLoadAddress(), kSweepBase + (i << 3));
-    EXPECT_EQ(GetEpoch(), ((i + 1) << 1) | 1);
+    EXPECT_EQ(GetEpoch(), 1);
     EXPECT_EQ(GetStatus(), 0);
   }
   // Step through the next capability. The sweep should be done.
   AdvanceRevoker();
   // Notice the in progress bit is cleared.
-  EXPECT_EQ(GetEpoch(), ((num + 1) << 1) | 0);
+  EXPECT_EQ(GetEpoch(), (1 << 1) | 0);
   // Interrupt status should be 0, as interrupt enable is off.
   EXPECT_EQ(GetStatus(), 0);
 }