Then people REALLY do leave and the government seeks to prevent people from leaving. The Berlin Wall and the Korean Border are excellent examples of this. The Great Wall under the Ming Dynasty is also supposed to have a secondary purpose. To keep the Barbarian hoarders out AND people IN. The UK used to have a totally open door migration policy, inwards because the government in the pocket of corporates like to lower wages. The migrants are happy because of wage arbitrage.
Thus it is actually a HK government issue. Although the CCP has powers over the HK government it is very rare for them to actually interfere overtly except in limited areas. So when the USS Nimitz docked, the HK government had to ask the PRC government. The PRC government said yes.... much to the delight of all the working women, bars and dealers in HK. But they have done some noticeable things. For example TV broadcasts first thing in the morning you get the PRC anthem, in schools soon children will be taught ONE China type thinking. But shadowy slight movements are harder to detect.
Boiling a frog is a very good example.
Hong Kong as said is a funny place, it is quite legal to buy your citizenship, you have to invest several million HK$ (I forget the exact amount) and you get citizenship right away. This is pissing off local HK people because there are many many wealthy people in China, this is causing lots of hot money to flow into HK stoking uberinflation where prices can and DO change daily (upwards) as the investment is often property. Which restricts supply and makes property which is already expensive in HK even more expensive.
Anyway as I mentioned in prior posts, Chinese people are internally racist to one another. Mainlanders are just another sect to which people can spit their bile to. As really there are benefits in HK, but it is rather low. $900-$1100 a month (HKD) but this is about the same as you'd get working in a shitty main lander job so it makes sense to them sometimes. Much like working for min wage makes sense for Eastern European migrants in the UK.
Anyway the HK government in 1997 one of the first things they implemented was the right to abode/return law. Meaning if you were born overseas but your parents were born in HK or the NT then you were granted 3* citizenship status. 3* status is full citizenship, which means uber subsidised health care (not dentistry) right to vote (in the rare occasions they do vote that is), right to government rebates like the $6000 stimulus thing (which is still not resolved) and also heavily virtually free education in HK. This law was overturned in 1999 on appeal. Which allowed a lot of people to 'return' as well as 400,000 people on the mainland also to take up residency.
This has been going back and forth for pretty much a decade about how there should be restrictions on mainland Chinese going to HK. It waxes and wanes. The last BIG issue I recall was the pregnant mainland women thing. Whereby mainland women who gave birth in HK their child would gain substantial benefits which you don't get in some parts of China. I.e. subbed health care, freeish education and many of the 3* benefits above. This annoyed a lot of people because it was seen that many people came across the border and got a free ride having not paid into the system. Such benefits to some looked attractive so the number of mainland women who did go to HK to give birth increased from about 4-8K a year to about 25K a year. The HK government responded by demanding a $5K bond if they were to travel to HK and were pregnant, though I'm not sure of the intricacies of this arrangement. Since I've never been pregnant or gotten anybody pregnant.... I think...
The issue that has flared up the tussle is the $6000 stimulus package amongst other things. I.e. people want to get the $6000 (a substantial amount in some areas of Mainland China) for nothing. TCG has and does pay into the HK tax system btw since a couple of my exist in cyberspace businesses are registered there. I.e people don't want to be paying it to others who are seen not to have earned it. Similar issues in the UK, if you've worked for ages and lose your job nobody is that fussed about if you are unemployed and claim welfare. However if you have never worked and claim it is seen as much less fair.
But to answer your original question, there are hoops to jump through which are increasing all of the time, but it is far from impossible for both HK and the wider world... I mean in Manchester China town there are many many restaurants staffed completely by mainland Chinese. 10-15 years ago they were staffed by Cantonese and Hakka migrants. Thus it WAS pretty easy for them to get in..... in a terrible irony I remember an illegal immigrant in the UK from Chongqing. He had hidden in a container to get to the UK. He was pretty pissed off to realise that the legal route was so much easier.