From f884ea13b713143ff9978092ddb352c159346167 Mon Sep 17 00:00:00 2001 From: Adin Scannell Date: Tue, 2 Feb 2021 12:01:12 -0800 Subject: Move ring0 package. This allows the package to serve as a general purpose ring0 support package, as opposed to being bound to specific sentry platforms. Updates #5039 PiperOrigin-RevId: 355220044 --- pkg/ring0/pagetables/BUILD | 88 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 pkg/ring0/pagetables/BUILD (limited to 'pkg/ring0/pagetables/BUILD') diff --git a/pkg/ring0/pagetables/BUILD b/pkg/ring0/pagetables/BUILD new file mode 100644 index 000000000..65a978cbb --- /dev/null +++ b/pkg/ring0/pagetables/BUILD @@ -0,0 +1,88 @@ +load("//tools:defs.bzl", "go_library", "go_test") +load("//tools/go_generics:defs.bzl", "go_template", "go_template_instance") + +package(licenses = ["notice"]) + +[ + # These files are tagged with relevant build architectures. We can always + # build all the input files, which will be included only in the relevant + # architecture builds. + go_template( + name = "generic_walker_%s" % arch, + srcs = [ + "walker_generic.go", + "walker_%s.go" % arch, + ], + opt_types = [ + "Visitor", + ], + visibility = [":__pkg__"], + ) + for arch in ("amd64", "arm64") +] + +[ + # See above. + go_template_instance( + name = "walker_%s_%s" % (op, arch), + out = "walker_%s_%s.go" % (op, arch), + package = "pagetables", + prefix = op, + template = ":generic_walker_%s" % arch, + types = { + "Visitor": "%sVisitor" % op, + }, + ) + for op in ("map", "unmap", "lookup", "empty", "check") + for arch in ("amd64", "arm64") +] + +go_library( + name = "pagetables", + srcs = [ + "allocator.go", + "allocator_unsafe.go", + "pagetables.go", + "pagetables_aarch64.go", + "pagetables_amd64.go", + "pagetables_arm64.go", + "pagetables_x86.go", + "pcids.go", + "pcids_aarch64.go", + "pcids_aarch64.s", + "pcids_x86.go", + "walker_amd64.go", + "walker_arm64.go", + "walker_generic.go", + ":walker_empty_amd64", + ":walker_empty_arm64", + ":walker_lookup_amd64", + ":walker_lookup_arm64", + ":walker_map_amd64", + ":walker_map_arm64", + ":walker_unmap_amd64", + ":walker_unmap_arm64", + ], + visibility = [ + "//pkg/ring0:__subpackages__", + "//pkg/sentry/platform/kvm:__subpackages__", + ], + deps = [ + "//pkg/sync", + "//pkg/usermem", + ], +) + +go_test( + name = "pagetables_test", + size = "small", + srcs = [ + "pagetables_amd64_test.go", + "pagetables_arm64_test.go", + "pagetables_test.go", + ":walker_check_amd64", + ":walker_check_arm64", + ], + library = ":pagetables", + deps = ["//pkg/usermem"], +) -- cgit v1.2.3